libGDX: Why doesn't Gdx.input.isKeyJustPressed() work?

I'm trying to use the method Gdx.input.isKeyJustPressed() to check if the Android BACK button was just pressed. I don't want to use the Gdx.input.isKeyPressed method to avoid multiple calls. Here is my code:

public void handleInput() {
if(Gdx.input.isKeyJustPressed(Input.Keys.BACK)) {
// show previous screen...
}
}

public void update(float dt) {
handleInput();
}


But unfortunately this doesn't work. Any ideas?

• This does work. Put a breakpoint inside handleInput() and see if the code is even reached, it's probably not and your missing a call to it somewhere deeper down the line. – Madmenyo Jul 21 '15 at 15:22
• @MennoGouw If I replace isKeyJustPressed() with isKeyPressed() it's working. The problem seems to be with the isKeyJustPressed() method. – Andreas Zock Jul 21 '15 at 16:13

Below code works for me, I get the message when pressing the back button.

if (Gdx.input.isKeyJustPressed(Input.Keys.BACK))
{
Gdx.app.log("Debug", "Back pressed!");
}


Are you calling below method before the one above?

    Gdx.input.setCatchBackKey(true);

• I also called the setCatchBackKey(true). But it it doesn't work. I'm going to use the isKeyPressed() method and prevent multiple calls by saving the last key state and make only a call when the last key state is different from the current. – Andreas Zock Jul 21 '15 at 21:56