在我的游戏中,我希望能够使用左右 shift 键来执行不同的功能.在 Java(或其他语言)中,有什么方法可以区分这两者吗?
In my game, I want to be able to use the right and left shift keys for different functions. In Java (or another language), is there any way to distinguish between those two?
KeyEvent类只有VK_SHIFT,对应左右shift键.与 Control、Alt、Enter 等相同.
The KeyEvent class has only VK_SHIFT, which corresponds to both left and right shift keys. Same with Control, Alt, Enter, etc.
我主要担心有人可能会用两根手指同时快速按下两个键,从而获得不公平的优势.我应该担心这个吗?
My primary concern is someone may be able to use two fingers to rapidly press both keys at the same time, gaining an unfair advantage. Should I be concerned about this?
我找到了一个包含 Java WebStart 示例和源代码的 Java 教程.看起来获胜者是 KeyEvent.getKeyLocation()
I found a Java tutorial that includes a Java WebStart sample and the source code. Looks like the winner is KeyEvent.getKeyLocation()
参考资料:
关键监听器演示和源代码
这篇关于如何判断按下了哪个 SHIFT 键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)