用java语言如何实现后台键盘监听
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; } } });