开发者

Eliminating Initial keypress delay

开发者 https://www.devze.com 2023-04-06 22:45 出处:网络
When you type into a textbox and hold a key, you get (a.......aaaaaaaaaaaaaaa), depending on the initial key press delay.

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 l开发者_Python百科uck.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消