Keyboard Events
Typing a single key generates a KeyEvent.
These events may be monitored directly by implementing the KeyListener interface (in java.awt.event):
interface KeyListener extends EventListener
void keyPressed (KeyEvent evt) ;
void keyReleased (KeyEvent evt) ;
void keyTyped (KeyEvent evt) ;
}
In the first two cases, evt.getKeyCode() returns a virtual key code—an int encoding of the key, e.g. VK_SHIFT, VK_A, . . .
In the third case the character on the key is returned by evt.getKeyChar()