有没有与主题中的问题相对应的解决方案。如果我按例如 Windows 键 + 空格键,我会得到:
键类型:Windows
我想应该是:
keyTyped:Windows
keyTyped:空格
keyReleased:Windows
keyReleased:空格
我的代码:
<Java component>.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
e.consume();
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println("keyTyped: " + KeyEvent.getKeyText(e.getKeyCode()));
e.consume();
}
@Override
public void keyReleased(KeyEvent e) {
System.out.println("keyReleased: " + KeyEvent.getKeyText(e.getKeyCode()));
e.consume();
}
});
谢谢!