private class KeyInputHandler extends KeyAdapter { /** The number of key presses we've had while waiting for an "any key" press */ private int pressCount = 1; /** * Notification from AWT that a key has been pressed. Note that * a key being pressed is equal to being pushed down but *NOT* * released. Thats where keyTyped() comes in. * * @param e The details of the key that was pressed */ public void keyPressed(KeyEvent e) { // if we're waiting for an "any key" typed then we don't // want to do anything with just a "press" if (e.getKeyCode() == KeyEvent.VK_LEFT) { } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { } if (e.getKeyCode() == KeyEvent.VK_SPACE) { } } /** * Notification from AWT that a key has been released. * * @param e The details of the key that was released */ public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { } if (e.getKeyCode() == KeyEvent.VK_SPACE) { } } /** * Notification from AWT that a key has been typed. Note that * typing a key means to both press and then release it. * * @param e The details of the key that was typed. */ public void keyTyped(KeyEvent e) { // if we hit escape, then quit the game if (e.getKeyChar() == 27) { System.exit(0); } } }