Buggy code:
public static final int ST_RUNNING = 0 ; public static final int ST_DIE = 1 ; public static final int ST_WIN = 2 ; public static final int ST_PAUSE = 3 ; public static final int ST_MENU = 4 ; public static final int ST_SETTINGS = 5 ; public static final int ST_CAMPAIGN = 6 ; private static LD31 context ; public static String [ ] args ; private Profiler profiler ; private InputHandler input ; private Audio audio ; private Level level ; private EndScreen win ; private EndScreen die ; private Menu mainMenu ; private Menu settingsMenu ; private Menu pauseMenu ; private Menu dummyCampaignMenu ; private volatile int gameState ; private int fadePhase ; private String currentLevel ; public Renderer renderer ; @ Override public void setup ( ) { LD31 . context = this ; renderer = new Renderer ( ) ; audio = new Audio ( ) ; profiler = new Profiler ( ) ; size ( 800 , 600 ) ; frameRate ( 60 ) ; noStroke ( ) ; frame . setResizable ( true ) ; frame . setTitle ( "Blockade<seq2seq4repair_space>Runner" ) ; audio . load ( LD31 . BG_MUSIC , VOL_MUSIC ) ; audio . shiftVolume ( VOL_MUSIC , 0.0F , 1.0F , ( 10 * 1000 ) ) ; audio . play ( LD31 . BG_MUSIC , true ) ; win = new EndScreen ( renderer . font , HUD . MSG_WIN , color ( 0 , 120 , 0 ) ) ; die = new EndScreen ( renderer . font , HUD . MSG_DIE , color ( 120 , 0 , 0 ) ) ; mainMenu = new Menu ( ) ; mainMenu . add ( new net . kopeph . ld31 . menu . TextBox ( renderer . font , "Blockade<seq2seq4repair_space>Runner" , 0 , ( - 175 ) ) ) ; mainMenu . add ( new MenuButton ( renderer . font , "Free<seq2seq4repair_space>Play" , 0 , ( - 100 ) , 400 , 50 , ( down ) -> { gameState = ST_RESET_HARD ; currentLevel = null ; } ) ) ; mainMenu . add ( new MenuButton ( renderer . font , "Campaign<seq2seq4repair_space>Mode" , 0 , ( - 40 ) , 400 , 50 , ( down ) -> { gameState = ST_CAMPAIGN ; } ) ) ; mainMenu . add ( new MenuButton ( renderer . font , "Settings" , 0 , ( + 20 ) , 400 , 50 , ( down ) -> { gameState = ST_SETTINGS ; } ) ) ; mainMenu . add ( new MenuButton ( renderer . font , "Exit" , 0 , ( + 120 ) , 400 , 50 , ( down ) -> { exit ( ) ; } ) ) ; input = new InputHandler ( ) ; input . loadKeyIdBindings ( ) ; input . bindControlCode ( CTL_RESET , ( down ) -> { if ( ( ( ( gameState ) == ( ST_RUNNING ) ) || ( ( gameState ) == ( ST_WIN ) ) ) || ( ( gameState ) == ( ST_DIE ) ) ) { gameState = ST_RESET ; } } ) ; input . bindControlCode ( CTL_PAUSE , ( down ) -> { if ( ( gameState ) == ( ST_RUNNING ) ) { gameState = ST_PAUSE ; menuHeight = 1 ; } else if ( ( gameState ) == ( ST_PAUSE ) ) { gameState = ST_RUNNING ; } } ) ; input . bindControlCode ( CTL_ESCAPE , ( down ) -> { if ( ( gameState ) == ( ST_MENU ) ) { exit ( ) ; } else <START_BUG> if ( ( gameState ) == ( ST_RUNNING ) ) { <END_BUG> gameState = ST_PAUSE ; menuHeight = 10 ; } else if ( ( gameState ) == ( ST_PAUSE ) ) { gameState = ST_RUNNING ; } else { gameState = ST_MENU ; } } ) ; settingsMenu = new Menu ( ) ; settingsMenu . add ( new net . kopeph . ld31 . menu . TextBox ( renderer . font , "Settings<seq2seq4repair_space>Menu" , 0 , ( - 175 ) ) ) ; final int MENU_COLS = 4 ; for ( int col = 1 ; col < MENU_COLS ; ++ col ) { settingsMenu . add ( new net . kopeph . ld31 . menu . TextBox ( renderer . font , String . valueOf ( col ) , ( ( ( - 30 ) * MENU_COLS ) + ( 60 * col ) ) , ( - 150 ) ) ) ; } for ( int row = 0 ; row < ( InputHandler . CTL_ESCAPE ) ; ++ row ) { settingsMenu . add ( new net . kopeph . ld31 . menu . TextBox ( renderer . font , InputHandler . getControlString ( row ) , ( ( - 30 ) * MENU_COLS ) , ( ( - 125 ) + ( 30 * row ) ) ) ) ; final int r = row ; List < Integer > bindings = input . getBoundKeyIdsFor ( row ) ; for ( int col = 1 ; col < MENU_COLS ; ++ col ) { final int keyId = ( col <= ( bindings . size ( ) ) ) ? bindings . get ( ( col - 1 ) ) : InputHandler . K_UNBOUND ; final MenuButton b = new MenuButton ( renderer . font , InputHandler . getKeyIdString ( keyId ) , ( ( ( - 30 ) * MENU_COLS ) + ( 60 * col ) ) , ( ( - 125 ) + ( 30 * row ) ) , 50 , 20 , ( down ) -> { } ) ; b . replaceInteraction ( ( down ) -> { input . handleBind ( b , r ) ; } ) ; b . tag = keyId ; settingsMenu . add ( b ) ; } }

Fix:
if ( ( ( ( gameState ) == ( ST_RUNNING ) ) || ( ( gameState ) == ( ST_WIN ) ) ) || ( ( gameState ) == ( ST_DIE ) ) ) {