Eliminate initial keypress delay

When you enter a text field and hold the key, you get (a ....... aaaaaaaaaaaaaaa) depending on the initial delay in pressing the key.

addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { // Handle key press here } 

I am creating a game in which user reflexes are very important. How can I completely eliminate this delay? The above code does not work. I also tried overriding processKeyEvent with no luck.

+7
source share
1 answer

These events are generated by the JVM / operating system, and if you did not tell the user to change the keyboard delay / key retry settings, I’m afraid you will have to do another job.

I suggest you create a timer that fires events at the correct speed, starts and stops the timer on keyPressed / keyReleased .

+2
source

All Articles