Java:绑定Windows密钥
问题描述:
答
它为我工作我用KeyEvent类的以下常量。
/**
* Constant for the Microsoft Windows "Windows" key.
* It is used for both the left and right version of the key.
* @see #getKeyLocation()
* @since 1.5
*/
public static final int VK_WINDOWS = 0x020C;
我实现我的KeyListener方法在下面的方式和它的工作(我使用Ubuntu 10):
// Invoked when a key has been pressed.
public void keyPressed(KeyEvent e) {
// Returns the integer code for the key on the keyboard and if
// keyCode is equal to VK_WINDOWS)...
if (e.getKeyCode() == KeyEvent.VK_WINDOWS) {
// ...call the doIT method.
doIT();
}
}
答
在Linux上,Windows密钥通常映射到元密钥,因此请尝试Event.META_MASK
。
Event.META_MASK并没有为我工作在Ubuntu 10 – YoK 2010-08-11 08:29:32
Ubuntu的映射到“超”。 Opensuse将其映射到“Meta”。你可以使用xmodmap来改变它。 – 2010-08-11 10:02:44