问题描述
我正在尝试使用Java中的Robot类并键入一些文本.不幸的是,我在查找方括号,此符号|
和此符号`的键代码时遇到问题.我在KeyEvent常量中找不到它们.我要使用它们,因为我键入的文本是西里尔字母,并且这些符号表示字母中的字符.预先感谢.
I'm trying to use the Robot class in Java and type some text. Unfortunately I'm having problems finding the key codes of the square brackets, this symbol |
and this symbol `. I can't find them in the KeyEvent constants. I want to use them, because the text i'm typing is in cyrillic and these symbols represent characters in the alphabet. Thanks in advance.
推荐答案
它位于 JavaDoc for KeyEvent
KeyEvent.VK_OPEN_BRACKET
和
KeyEvent.VK_CLOSE_BRACKET
修改
从KeyEvent
JavaDoc
因此,在美国101键键盘上,尽管将具有和将产生相同的键码. > SHIFT 修改器.另请注意,KeyEvent.VK_BACK_SLASH
也会捕获(管道)按键.
So on a US 101-key keyboard, the and will produce the same keycode, although will have a modifier. Also notice that KeyEvent.VK_BACK_SLASH
traps the (pipe) keystroke too.
尝试将以下示例KeyAdapter
添加到您的项目中,以查看实际效果.
Try adding the following sample KeyAdapter
to your project to see this in action.
new KeyAdapter()
{
public void keyPressed(final KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_BACK_QUOTE)
{
e.toString();
}
if (e.getKeyCode() == KeyEvent.VK_BACK_SLASH)
{
e.toString();
}
if (e.getKeyCode() == KeyEvent.VK_OPEN_BRACKET)
{
e.toString();
}
}
}
这篇关于方括号的键码是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!