在我的一个菜单中,一个menuItem的快捷键是
Ctrl+更大
代码是 KeyEvent.VK_GREATER, Event.CTRL_MASK
但是当我按下 Ctrl+Greater 时,它不起作用.... 任何人都可以提出建议吗?
最佳答案
以为这个相当老的麻烦已经被修复了..显然不是;-)
在过去,在美式键盘布局中,只有在 键盘布局中使用具有 VK_Something 且无需 shift 即可访问 Something 的 keyStrokes 才是安全的。这意味着,对位置(不带 shift 或什至通过 gr)与该基数不同的键使用键绑定(bind)要么高度依赖键盘布局要么高度不稳定 - 最好不要使用。
// technical binding to "Greater" on a German keyboard
other.setAccelerator(KeyStroke.getKeyStroke("control shift LESS"));
// BUT ... not really, its localized description is
Str-Umschalt-Kleiner als
关于Java Swing 按键事件库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5870685/