Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent the keyPressed event from continuously firing when a key is held down without being released? #470

Open
formatsystem opened this issue Sep 11, 2024 · 2 comments

Comments

@formatsystem
Copy link

Hello.
My idea is that after pressing the specified key, KeyPressed should only be executed once without releasing the key, instead of continuously executing nativeKeyPressed in a loop while the key is held down. How can I improve this?

@kwhat
Copy link
Owner

kwhat commented Sep 11, 2024 via email

@formatsystem
Copy link
Author

It's called key bounce and it was an internal design feature. The rate at which the key bounces should be the value of the jnativehook.key.repeat.rate property and the delay until the bounce starts is the jnativehook.key.repeat.delay. If you don't want or need the repeat, set a flag where you are listening for events and ignore the subsequent key press events. What type of flag depends on how you want the ignore to work.

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants