[Chapter 21] KeyAdapter

#

| Chapter 21 java.awt.event Reference |

# KeyAdapter

## Name

KeyAdapter

##

## Description

The `KeyAdapter` class implements the methods of `KeyListener` with empty functions. It may be easier for you to extend `KeyAdapter`, overriding only those methods you are interested in, than to implement `KeyListener` and provide the empty functions yourself.

## Class Definition

    public abstract class java.awt.event.KeyAdapter
       extends java.lang.Object
       implements java.awt.event.KeyListener {
      // Instance Methods
      public void keyPressed (KeyEvent e);
      public void keyReleased (KeyEvent e);
      public void keyTyped (KeyEvent e);
    }

## Instance Methods

### keyPressed

#### public void keyPressed (KeyEvent e)

Parameters

  e

    The event that has occurred.

Description

  Does nothing. Override this function to be notified when a key is pressed.

### keyReleased

#### public void keyReleased (KeyEvent e)

Parameters

  e

    The event that has occurred.

Description

  Does nothing. Override this function to be notified when a pressed key is released.

### keyTyped

#### public void keyTyped (KeyEvent e)

Parameters

  e

    The event that has occurred.

Description

  Does nothing. Override this function to be notified when a key has been pressed and released.

## See Also

`KeyEvent`, `KeyListener`

ItemListener |  | KeyEvent