无法将 Control-Backspace 映射到 KeyStroke
我在将 Control-Backspace 键映射到 KeyStroke 时遇到问题。以下内容对我来说毫无意义。
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
public class TestControlBackspace {
public static void main(String[] args) {
KeyStroke ks1 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_CONTROL);
KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_SHIFT);
KeyStroke ks3 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0);
System.out.println(ks1);
System.out.println(ks2);
System.out.println(ks3);
}
}
输出:
shift 按下 BACK_SPACE
按下 BACK_SPACE
按下 BACK_SPACE
我在这里遗漏了什么吗?
I am having trouble mapping the Control-Backspace key to a KeyStroke. The following makes no sense to me.
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
public class TestControlBackspace {
public static void main(String[] args) {
KeyStroke ks1 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_CONTROL);
KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_SHIFT);
KeyStroke ks3 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0);
System.out.println(ks1);
System.out.println(ks2);
System.out.println(ks3);
}
}
Output:
shift pressed BACK_SPACE
pressed BACK_SPACE
pressed BACK_SPACE
Am I missing something here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能忘记阅读
You probably forgot to read the documentation. Note that the modifier masks come from a different location than the key pressed.