Can anybody tell me if there is a possibility to capture back button twice in same activity in libgdx. What i want to achieve is that if the user press back button once the game pause. if in the pause screen user press back key again so the level exit. This happens well in "Video" that is the built in app in android OS. During video play a if user press back button it toast to press back again to exit.

so I want somthing like this.

if (Gdx.input.isKeyPressed(Keys.BACK)) {

        code to call game pause  state

  if (Gdx.input.isKeyPressed(Keys.BACK)){   //// is this possible? 

  game.setScreen(new Menu(game))


    } else {
        code to call game resume state
  • \$\begingroup\$ I have solved this issue by calling if (Gdx.input.isKeyJustPressed(Keys.BACK)) once to pause game and if the game if is pause state then I called it again (if (Gdx.input.isKeyJustPressed(Keys.BACK)))to set screen to menu. So justPressed is capturing the event for once just . \$\endgroup\$ – Aiman Batul Feb 20 '15 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.