Package org.eclipse.swt.events

# Interface KeyListener

All Superinterfaces:
  `EventListener`

All Known Implementing Classes:
  `AnnotationBarHoverManager.Closer`, `ContentAssistant.AutoAssistListener`, `HyperlinkManager`, `KeyAdapter`, `PaintManager`

public interface KeyListener extends EventListener
Classes which implement this interface provide methods that deal with the events that are generated as keys are pressed on the system keyboard.

After creating an instance of a class that implements this interface it can be added to a control using the `addKeyListener` method and removed using the `removeKeyListener` method. When a key is pressed or released, the appropriate method will be invoked.

See Also:
  - `KeyAdapter`
  - `KeyEvent`

## Method Summary

Modifier and Type
Method
Description
`void`
`keyPressed(KeyEvent e)`
Sent when a key is pressed on the system keyboard.
`static KeyListener`
`keyPressedAdapter(Consumer<KeyEvent> c)`
Static helper method to create a `KeyListener` for the `keyPressed(KeyEvent e)`) method with a lambda expression.
`void`
`keyReleased(KeyEvent e)`
Sent when a key is released on the system keyboard.
`static KeyListener`
`keyReleasedAdapter(Consumer<KeyEvent> c)`
Static helper method to create a `KeyListener` for the `keyReleased(KeyEvent e)`) method with a lambda expression.

## Method Details

### keyPressed

void keyPressed(KeyEvent e)
Sent when a key is pressed on the system keyboard.

Parameters:
  `e` - an event containing information about the key press

### keyReleased

void keyReleased(KeyEvent e)
Sent when a key is released on the system keyboard.

Parameters:
  `e` - an event containing information about the key release

### keyPressedAdapter

static KeyListener keyPressedAdapter(Consumer<KeyEvent> c)
Static helper method to create a `KeyListener` for the `keyPressed(KeyEvent e)`) method with a lambda expression.

Parameters:
  `c` - the consumer of the event
Returns:
  KeyListener
Since:
  3.106

### keyReleasedAdapter

static KeyListener keyReleasedAdapter(Consumer<KeyEvent> c)
Static helper method to create a `KeyListener` for the `keyReleased(KeyEvent e)`) method with a lambda expression.

Parameters:
  `c` - the consumer of the event
Returns:
  KeyListener
Since:
  3.106