Loading...
Searching...
No Matches
juce::KeyListener Class Referenceabstract

## Detailed Description

Receives callbacks when keys are pressed.

You can add a key listener to a component to be informed when that component gets key events. See the Component::addKeyListener method for more details.

See also
  KeyPress, Component::addKeyListener, KeyPressMappingSet

The documentation for this class was generated from the following file:

- juce_gui_basics/keyboard/juce_KeyListener.h

Inheritance diagram for juce::KeyListener:

## Public Member Functions

virtual | ~KeyListener ()=default
| Destructor.
virtual bool | keyPressed (const KeyPress &key, Component *originatingComponent)=0
| Called to indicate that a key has been pressed.
virtual bool | keyStateChanged (bool isKeyDown, Component *originatingComponent)
| Called when any key is pressed or released.

## Constructors and Destructors

## ~KeyListener()

virtual juce::KeyListener::~KeyListener | ( |  | ) |

virtual default

Destructor.

## Member Functions

## keyPressed()

virtual bool juce::KeyListener::keyPressed | ( | const KeyPress & | key,
|  | Component * | originatingComponent )

pure virtual

Called to indicate that a key has been pressed.

If your implementation returns true, then the key event is considered to have been consumed, and will not be passed on to any other components. If it returns false, then the key will be passed to other components that might want to use it.

Parameters

  key | the keystroke, including modifier keys
  originatingComponent | the component that received the key event

See also
  keyStateChanged, Component::keyPressed

Implemented in juce::KeyPressMappingSet.

## keyStateChanged()

virtual bool juce::KeyListener::keyStateChanged | ( | bool | isKeyDown,
|  | Component * | originatingComponent )

virtual

Called when any key is pressed or released.

When this is called, classes that might be interested in the state of one or more keys can use KeyPress::isKeyCurrentlyDown() to check whether their key has changed.

If your implementation returns true, then the key event is considered to have been consumed, and will not be passed on to any other components. If it returns false, then the key will be passed to other components that might want to use it.

Parameters

  originatingComponent | the component that received the key event
  isKeyDown | true if a key is being pressed, false if one is being released

See also
  KeyPress, Component::keyStateChanged

Reimplemented in juce::KeyPressMappingSet.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited