Reputation: 94
I'm working on a game with libgdx, the game only has one button witch makes the player jump. I'm trying to figure out a way to make it possible for the user to rebind that key to whatever key they want. In the keyUp and keyDown methods you get a keycode and im wondering if there is any other way to check what key that is instead of going over all the keys like.
if(keycode == Input.Keys.A){}
if(keycode == Input.Keys.B){}
if(keycode == Input.Keys.C){}
And so on.
Upvotes: 1
Views: 7449
Reputation: 3819
You are using Libgdx so try this
if(Gdx.input.isKeyPressed(Keys.ANY_KEY)) {
// your actions
jump();
}
Put this code inside the render() function so the jump() function will be called if any key of keyboard is pressed
Good luck !
Upvotes: 5