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; } } });
- 相关评论
- 我要评论
-