JUCE  v5.1.1-3-g1a0b28c73
JUCE API
KeyListener Class Referenceabstract

Receives callbacks when keys are pressed. More...

#include <juce_KeyListener.h>

Inheritance diagram for KeyListener:

Public Member Functions

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

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::addListener method for more details.

See also
KeyPress, Component::addKeyListener, KeyPressMappingSet

Constructor & Destructor Documentation

◆ ~KeyListener()

virtual KeyListener::~KeyListener ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ keyPressed()

virtual bool 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
keythe keystroke, including modifier keys
originatingComponentthe component that received the key event
See also
keyStateChanged, Component::keyPressed

Implemented in KeyPressMappingSet.

Referenced by KeyPressMappingSet::getCommandManager().

◆ keyStateChanged()

virtual bool 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
originatingComponentthe component that received the key event
isKeyDowntrue if a key is being pressed, false if one is being released
See also
KeyPress, Component::keyStateChanged

Reimplemented in KeyPressMappingSet.

Referenced by KeyPressMappingSet::getCommandManager().


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