简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM