开发者

Eliminating Initial keypress 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜