Alejandro Garcia
Alejandro Garcia

Reputation: 1221

How to use KeyListener to capture ONLY when the key has been pressed

I know how the KeyListener works, however the problem is that the abstract method KeyPressed doesn't works as I expect. Instead of calling the function each key press, calls the function all the time the key is being pressed. Is it possible to handle only when I press the key and not when its being pressed?

Upvotes: 0

Views: 157

Answers (1)

Stefan
Stefan

Reputation: 12453

Implement KeyListener and override keyPressed. Set a value that is kept until keyReleased is invoked.

Upvotes: 2

Related Questions