我希望 leftCanvas 捕获所有键盘事件,包括 Control + Space 。我怎样才能实现这一点,因为它触发了原生的InputMethod
?
class leftCanvas extends Canvas implements KeyListener {
leftCanvas() {
addKeyListener(this);
enableInputMethods(false);
}
public void keyTyped(KeyEvent event) {
System.out.println(event.getKeyChar());
event.consume();
}
public void keyPressed(KeyEvent event) {
event.consume();
}
public void keyReleased(KeyEvent event) {
event.consume();
}
}