Saving a switch input to choose mode of operation

why not use the keypress to set a (global/static) "mode" variable that determines which mode to invoke?