如何在Java的KeyStroke.getKeystroke的String版本中引用mac命令键? [英] How do you refer to the mac command key in the String version of Java's KeyStroke.getKeystroke?
问题描述
KeyStroke.getKeystroke(String)的文档(例如, getKeyStroke(control DELETE)
)没有提供如何访问macintosh命令键的示例,我找不到一个引用,列出了这个函数接受的修饰符,如控制的各种单词的拼写。命令键的语法是什么?
The documentation for KeyStroke.getKeystroke(String) (e.g., getKeyStroke("control DELETE")
) does not provide an example of how to access the macintosh command key, and I can't find a reference that lists the spellings of the various words for modifiers like "control" that this function accepts. What is the syntax for the command key?
作为参考,这里是getKeystroke的文档:
For reference, here's the documentation for getKeystroke:
解析一个字符串并返回 KeyStroke
。
该字符串必须具有以下语法:
Parses a string and returns a KeyStroke
.
The string must have the following syntax:
<modifiers>* (<typedID> | <pressedReleasedID>)
modifiers := shift | control | ctrl | meta | alt | altGraph
typedID := typed <typedKey>
typedKey := string of length 1 giving Unicode character.
pressedReleasedID := (pressed | released) key
key := KeyEvent key code name, i.e. the name following "VK_".
如果未指定键入,按下或释放,则按下。这里
是一些例子:
If typed, pressed or released is not specified, pressed is assumed. Here are some examples:
"INSERT" => getKeyStroke(KeyEvent.VK_INSERT, 0);
"control DELETE" => getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);
"alt shift X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
"alt shift released X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);
"typed a" => getKeyStroke('a');
推荐答案
我不得不去AWTKeyStroke的源代码getAWTKeyStroke(String s)来查看全部可接受的修饰词术语,然后做一些试验和错误,检查命令键的修饰语法是meta。
I had to go to the source code for AWTKeyStroke getAWTKeyStroke(String s) to see all of the acceptable modifier terms, and then do a little trial and error, to check that the modifier syntax for the command key is "meta".
这篇关于如何在Java的KeyStroke.getKeystroke的String版本中引用mac命令键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!