[Chapter 21] KeyListener
Author: John Zukowski
Date: Thu Jul 31 15:22:10 1997

#

| Chapter 21 java.awt.event Reference |

# KeyListener

## Name

KeyListener

##

## Description

Objects that implement the `KeyListener` interface can receive `KeyEvent` objects. Listeners must first register themselves with objects that produce events. When events occur, they are then automatically propagated to all registered listeners.

## Interface Definition

    public abstract interface java.awt.event.KeyListener
       extends java.util.EventListener {
      // Instance Methods
      public abstract void keyPressed (KeyEvent e);
      public abstract void keyReleased (KeyEvent e);
      public abstract void keyTyped (KeyEvent e);
    }

## Interface Methods

### keyPressed

#### public abstract void keyPressed (KeyEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `KeyListener` that a key was pressed.

### keyReleased

#### public abstract void keyReleased (KeyEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `KeyListener` that a key was released.

### keyTyped

#### public abstract void keyTyped (KeyEvent e)

Parameters

  e

    The key event that occurred.

Description

  Notifies the `KeyListener` that a key was typed (pressed and released).

## See Also

`AWTEventMulticaster`, `EventListener`, `KeyEvent`, `KeyListener`

KeyEvent |  | MouseAdapter