When you type into a textbox and hold a key, you get (a.......aaaaaaaaaaaaaaa), depending on the initial key press delay.
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
// Handle key press here
}
I'm creating a game in which the user's reflexes are very important. How can I eliminate this delay completely? The above code does not work. I have also tried overriding processKeyEvent with no luck.
These events are generated by the JVM / operating system, and unless you instruct the user to change the key-delay / key-repeat settings I'm afraid you'll have to do some more work.
I suggest you create a Timer which fires events in the correct rate, start and stop the timer upon keyPressed
/ keyReleased
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With