Minecraft wiki entry for Development_versions, associated text: Added quick game mode switching functionality using the F3 debug key.
Hold F3 and press F4 to open the menu. Pressing F4 or using the mouse will cycle the game mode. Release F3 to apply.
The last game mode is remembered and will be the first selected option, so it is possible to quickly toggle between two game modes with a single press of F3 + F4.
F3 + N now toggles between spectator mode and the previous game of the player.