消除初始键preSS延迟 [英] Eliminating Initial keypress delay

查看:163
本文介绍了消除初始键preSS延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你输入到一个文本框,并按住一个键,你就会得到(一....... aaaaaaaaaaaaaaa),这取决于初始密钥preSS延迟。

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
    }

我创建一个游戏中,用户的反应能力是非常重要的。我怎样才能彻底消除这种延迟?以上code不起作用。我也曾尝试重写processKeyEvent没有运气。

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.

推荐答案

这些事件是由JVM /操作系统生成的,除非你指导用户更改密钥延迟/键重复设置,我怕你将不得不做更多的工作。

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.

我建议你创建一个触发事件的正确率定时器,启动和停止时键pressed / 的keyReleased <计时器/ code>。

I suggest you create a Timer which fires events in the correct rate, start and stop the timer upon keyPressed / keyReleased.

这篇关于消除初始键preSS延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆