public class KeyEvent
extends InputEvent
An event which indicates that a keystroke occurred in a component.
This event is generated by a component object (such as a text field) when a key is
pressed, released, or typed. The event is passed to every KeyListener or KeyAdapter object
which registered to receive such events using the component's addKeyListener method.
(KeyAdapter objects implement the KeyListener interface.) Each such listener object gets this KeyEvent when the event occurs.
and using that event object, you can get the event details like what key has been pressed using e.getKeyCode()
some more methods like that.