1
\$\begingroup\$

I'm trying to figure it out how to check if keyboard key was released. I tried messing around with InputMultiplexer, InputProcessor, etc. Nothing helped. Not enough documentation from lib developers (at least for me).

Anyone had similar problem? Can someone help me?

With InputProcessor I can check if single key was pressed. But what if I want to check multiple keys?

\$\endgroup\$
2
\$\begingroup\$

There are two ways I can think of to accomplish this.

  1. In the InputProcessor keyPressed method you could save the key state in a map. You'll have to use the keyReleased method to set the key state to released. This way you can just check the map to make sure the right keys are pressed.

  2. Inside your update/render method call Gdx.input.isKeyPressed(Input.Keys.Key) to see if a key is pressed. This way you are polling input every frame to check for the key combination.

I personally would use method 2, but pick whatever will suit your app best. I might be able to expand on my answer more tomorrow when I'm on my Desktop. Hopefully for now this will get you going in the right direction.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.