While playing the game press the forward-slash key (/) and a small window will pop up. Enter the code, press enter and this will be enough to have your command activated.
This command is for changing the game mode. If you want to change the mode for a selected player, you need to add the player’s name at the end of the code. Instead of “” enter one of the options below:
For instance: /gamemode Survival