返回首页

用java语言如何实现后台键盘监听?

107 2024-01-03 01:17 admin

this.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { int keycode = e.getKeyCode(); switch (keycode) { case KeyEvent.VK_UP: { //do something break; } case KeyEvent.VK_DOWN: { //do something break; } case KeyEvent.VK_LEFT: { //do something break; } case KeyEvent.VK_RIGHT: { //do something break; } default: break; } } });

顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
用户名: 验证码:点击我更换图片

网站地图 (共14个专题26197篇文章)

返回首页