libgdx/libgdx

Add keyHeldDown in com.badlogic.gdx.scenes.scene2d.InputListener

patton73 opened this issue · 2 comments

This is another feature request.

I would ask if possible to have another method into com.badlogic.gdx.scenes.scene2d.InputListener for the keyboard.
it has keyDown and keyUP but it does not have a keyHeldDown method.
It would be really nice to have it.
Right now the code to check if a key is held down for an Actor is really tricky and quite ugly.

Andrea.

An event-based version of if (this.hasKeyboardFocus() && Gdx.input.isKeyPressed(...))? Would it fire once per key per frame, sorta like keyTyped() but tied to the frame rate rather than the typematic rate? Perhaps an example would help me better understand.

This kind of thing is game specific imho and easy to code in your game, so i wouldn't add this to the framework. You could have a boolean array in your actor class that keep track of keys : set to true on keyDown, set to false on keyUp.

Feel free to ask for help in Discord to implement a clean solution for this specific need.