Bedrock edition

Anyone know how to make it so when you hold an item in your hand you go into a different game mode? I'm trying to make a map that allows you to go into Spectator mode for 30 secs but idk how to do it.