title: Libgdx: phone's back button continues between screen
body: <p>I have three classes that implement LibGdx Screen class:</p>
  
  <p>MainMenuScreen, LevelSelectScreen, GameScreen</p>
  
  <p>For now I have MainMenuScreen's setCatchBackKey set to false, so the game will just exit on back press.</p>
  
  <p>LevelSelectScreen and GameScreen have setCatchBackKey set to true.</p>
  
  <p>Within the GameScreen's render function I have:</p>
  
  <pre><code>@Override
  public void render(float delta)
  {
      gameTime = delta;
  
      if (Gdx.input.isKeyPressed(Keys.BACK))
         new LevelSelectScreen(game);
  
      ...
  }
  </code></pre>
  
  <p>which sets the screen to show level select and in LevelSelectScreens's render function I have:</p>
  
  <pre><code>@Override
  public void render(float delta)
  {
      if (Gdx.input.isKeyPressed(Keys.BACK))
          new MainMenuScreen(game);
  
      Update();
      Draw();
  } //end render
  </code></pre>
  
  <p>The problem I run into with this is that when I press back on the GameScreen the LevelSelectScreen flashes to the screen for a moment and then straight back to the MainMenuScreen.</p>
  
  <p>I figure that I could set some variable to check whether Back is already being pushed when the screen initializes, but was just curious if there is some "magical" function already included within LibGdx or just code structure that would also work around this problem.</p>