0
\$\begingroup\$

This question already has an answer here:

Have a question on keyboard inputs. Currently I am using this method to read my input, Gdx.input.isKeyPressed(Input.Keys.A), it is working fine. But I do realized at times there are multiple instances of A being pressed when I only press once. And I understand that the method had to be placed in the render() method for it to work. Is the problem due to the refreshing?

My question is, how can I only detect 1 instance of "A", when A is pressed for once.

\$\endgroup\$

marked as duplicate by aaaaaaaaaaaa, Seth Battin, MichaelHouse Oct 2 '13 at 21:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Maybe I should clarify myself, when i detected the key then the textfield will be updated with the input. \$\endgroup\$ – leDon Oct 1 '13 at 14:49
  • \$\begingroup\$ Eh, I think i got what you mean, Thanks for the help :) \$\endgroup\$ – leDon Oct 1 '13 at 14:59
1
\$\begingroup\$

LibGdx library provided an InputProcessor Interface, I think you are better to implement the InputProcessor and you should set Screen's input processor to the class you made, see tutorials that dermetfan user made on youtube http://www.youtube.com/user/dermetfan/videos

however you may would like to use different methods, also check DeviceInfo of LibGdx for checking devices.

\$\endgroup\$
-1
\$\begingroup\$

store the current keys state, get the new ones and

if(newInput.isKeyPressed(Input.Keys.A) && oldInput.isKeyUp(Input.Keys.A))
\$\endgroup\$

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