JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
juce::KeyPress Class Reference

Represents a key press, including any modifier keys that are needed. More...

#include "juce_KeyPress.h"

Public Member Functions

 KeyPress ()=default
 Creates an (invalid) KeyPress.
 
 ~KeyPress ()=default
 Destructor.
 
 KeyPress (int keyCode, ModifierKeys modifiers, juce_wchar textCharacter) noexcept
 Creates a KeyPress for a key and some modifiers.
 
 KeyPress (int keyCode) noexcept
 Creates a keypress with a keyCode but no modifiers or text character.
 
 KeyPress (const KeyPress &)=default
 Creates a copy of another KeyPress.
 
KeyPressoperator= (const KeyPress &)=default
 Copies this KeyPress from another one.
 
bool operator== (const KeyPress &other) const noexcept
 Compares two KeyPress objects.
 
bool operator!= (const KeyPress &other) const noexcept
 Compares two KeyPress objects.
 
bool operator== (int keyCode) const noexcept
 Returns true if this keypress is for the given keycode without any modifiers.
 
bool operator!= (int keyCode) const noexcept
 Returns true if this keypress is not for the given keycode without any modifiers.
 
bool isValid () const noexcept
 Returns true if this is a valid KeyPress.
 
int getKeyCode () const noexcept
 Returns the key code itself.
 
ModifierKeys getModifiers () const noexcept
 Returns the key modifiers.
 
juce_wchar getTextCharacter () const noexcept
 Returns the character that is associated with this keypress.
 
bool isKeyCode (int keyCodeToCompare) const noexcept
 Checks whether the KeyPress's key is the same as the one provided, without checking the modifiers.
 
String getTextDescription () const
 Creates a textual description of the key combination.
 
String getTextDescriptionWithIcons () const
 Creates a textual description of the key combination, using unicode icon symbols if possible.
 
bool isCurrentlyDown () const
 Checks whether the user is currently holding down the keys that make up this KeyPress.
 

Static Public Member Functions

static KeyPress createFromDescription (const String &textVersion)
 Converts a textual key description to a KeyPress.
 
static bool isKeyCurrentlyDown (int keyCode)
 Checks whether a particular key is held down, irrespective of modifiers.
 

Static Public Attributes

static const int spaceKey
 key-code for the space bar
 
static const int escapeKey
 key-code for the escape key
 
static const int returnKey
 key-code for the return key
 
static const int tabKey
 key-code for the tab key
 
static const int deleteKey
 key-code for the delete key (not backspace)
 
static const int backspaceKey
 key-code for the backspace key
 
static const int insertKey
 key-code for the insert key
 
static const int upKey
 key-code for the cursor-up key
 
static const int downKey
 key-code for the cursor-down key
 
static const int leftKey
 key-code for the cursor-left key
 
static const int rightKey
 key-code for the cursor-right key
 
static const int pageUpKey
 key-code for the page-up key
 
static const int pageDownKey
 key-code for the page-down key
 
static const int homeKey
 key-code for the home key
 
static const int endKey
 key-code for the end key
 
static const int F1Key
 key-code for the F1 key
 
static const int F2Key
 key-code for the F2 key
 
static const int F3Key
 key-code for the F3 key
 
static const int F4Key
 key-code for the F4 key
 
static const int F5Key
 key-code for the F5 key
 
static const int F6Key
 key-code for the F6 key
 
static const int F7Key
 key-code for the F7 key
 
static const int F8Key
 key-code for the F8 key
 
static const int F9Key
 key-code for the F9 key
 
static const int F10Key
 key-code for the F10 key
 
static const int F11Key
 key-code for the F11 key
 
static const int F12Key
 key-code for the F12 key
 
static const int F13Key
 key-code for the F13 key
 
static const int F14Key
 key-code for the F14 key
 
static const int F15Key
 key-code for the F15 key
 
static const int F16Key
 key-code for the F16 key
 
static const int F17Key
 key-code for the F17 key
 
static const int F18Key
 key-code for the F18 key
 
static const int F19Key
 key-code for the F19 key
 
static const int F20Key
 key-code for the F20 key
 
static const int F21Key
 key-code for the F21 key
 
static const int F22Key
 key-code for the F22 key
 
static const int F23Key
 key-code for the F23 key
 
static const int F24Key
 key-code for the F24 key
 
static const int F25Key
 key-code for the F25 key
 
static const int F26Key
 key-code for the F26 key
 
static const int F27Key
 key-code for the F27 key
 
static const int F28Key
 key-code for the F28 key
 
static const int F29Key
 key-code for the F29 key
 
static const int F30Key
 key-code for the F30 key
 
static const int F31Key
 key-code for the F31 key
 
static const int F32Key
 key-code for the F32 key
 
static const int F33Key
 key-code for the F33 key
 
static const int F34Key
 key-code for the F34 key
 
static const int F35Key
 key-code for the F35 key
 
static const int numberPad0
 key-code for the 0 on the numeric keypad.
 
static const int numberPad1
 key-code for the 1 on the numeric keypad.
 
static const int numberPad2
 key-code for the 2 on the numeric keypad.
 
static const int numberPad3
 key-code for the 3 on the numeric keypad.
 
static const int numberPad4
 key-code for the 4 on the numeric keypad.
 
static const int numberPad5
 key-code for the 5 on the numeric keypad.
 
static const int numberPad6
 key-code for the 6 on the numeric keypad.
 
static const int numberPad7
 key-code for the 7 on the numeric keypad.
 
static const int numberPad8
 key-code for the 8 on the numeric keypad.
 
static const int numberPad9
 key-code for the 9 on the numeric keypad.
 
static const int numberPadAdd
 key-code for the add sign on the numeric keypad.
 
static const int numberPadSubtract
 key-code for the subtract sign on the numeric keypad.
 
static const int numberPadMultiply
 key-code for the multiply sign on the numeric keypad.
 
static const int numberPadDivide
 key-code for the divide sign on the numeric keypad.
 
static const int numberPadSeparator
 key-code for the comma on the numeric keypad.
 
static const int numberPadDecimalPoint
 key-code for the decimal point sign on the numeric keypad.
 
static const int numberPadEquals
 key-code for the equals key on the numeric keypad.
 
static const int numberPadDelete
 key-code for the delete key on the numeric keypad.
 
static const int playKey
 key-code for a multimedia 'play' key, (not all keyboards will have one)
 
static const int stopKey
 key-code for a multimedia 'stop' key, (not all keyboards will have one)
 
static const int fastForwardKey
 key-code for a multimedia 'fast-forward' key, (not all keyboards will have one)
 
static const int rewindKey
 key-code for a multimedia 'rewind' key, (not all keyboards will have one)
 

Detailed Description

Represents a key press, including any modifier keys that are needed.

E.g. a KeyPress might represent CTRL+C, SHIFT+ALT+H, Spacebar, Escape, etc.

See also
Component, KeyListener, KeyPressMappingSet, Button::addShortcut

@tags{GUI}

Definition at line 39 of file juce_KeyPress.h.

Constructor & Destructor Documentation

◆ KeyPress() [1/3]

juce::KeyPress::KeyPress ( )
default

Creates an (invalid) KeyPress.

See also
isValid

◆ KeyPress() [2/3]

juce::KeyPress::KeyPress ( int  keyCode,
ModifierKeys  modifiers,
juce_wchar  textCharacter 
)
noexcept

Creates a KeyPress for a key and some modifiers.

e.g. CTRL+C would be: KeyPress ('c', ModifierKeys::ctrlModifier, 0) SHIFT+Escape would be: KeyPress (KeyPress::escapeKey, ModifierKeys::shiftModifier, 0)

Parameters
keyCodea code that represents the key - this value must be one of special constants listed in this class, or an 8-bit character code such as a letter (case is ignored), digit or a simple key like "," or ".". Note that this isn't the same as the textCharacter parameter, so for example a keyCode of 'a' and a shift-key modifier should have a textCharacter value of 'A'.
modifiersthe modifiers to associate with the keystroke
textCharacterthe character that would be printed if someone typed this keypress into a text editor. This value may be null if the keypress is a non-printing character
See also
getKeyCode, isKeyCode, getModifiers

Definition at line 29 of file juce_KeyPress.cpp.

◆ KeyPress() [3/3]

juce::KeyPress::KeyPress ( int  keyCode)
explicitnoexcept

Creates a keypress with a keyCode but no modifiers or text character.

Definition at line 34 of file juce_KeyPress.cpp.

Member Function Documentation

◆ createFromDescription()

KeyPress juce::KeyPress::createFromDescription ( const String textVersion)
static

Converts a textual key description to a KeyPress.

This attempts to decode a textual version of a keypress, e.g. "ctrl + c" or "spacebar".

This isn't designed to cope with any kind of input, but should be given the strings that are created by the getTextDescription() method.

If the string can't be parsed, the object returned will be invalid.

See also
getTextDescription

Definition at line 174 of file juce_KeyPress.cpp.

◆ getKeyCode()

int juce::KeyPress::getKeyCode ( ) const
noexcept

Returns the key code itself.

This will either be one of the special constants defined in this class, or an 8-bit character code.

Definition at line 109 of file juce_KeyPress.h.

◆ getModifiers()

ModifierKeys juce::KeyPress::getModifiers ( ) const
noexcept

Returns the key modifiers.

See also
ModifierKeys

Definition at line 115 of file juce_KeyPress.h.

◆ getTextCharacter()

juce_wchar juce::KeyPress::getTextCharacter ( ) const
noexcept

Returns the character that is associated with this keypress.

This is the character that you'd expect to see printed if you press this keypress in a text editor or similar component.

Definition at line 122 of file juce_KeyPress.h.

◆ getTextDescription()

String juce::KeyPress::getTextDescription ( ) const

Creates a textual description of the key combination.

e.g. "ctrl + c" or "delete".

To store a keypress in a file, use this method, along with createFromDescription() to retrieve it later.

Definition at line 229 of file juce_KeyPress.cpp.

◆ getTextDescriptionWithIcons()

String juce::KeyPress::getTextDescriptionWithIcons ( ) const

Creates a textual description of the key combination, using unicode icon symbols if possible.

On OSX, this uses the Apple symbols for command, option, shift, etc, instead of the textual modifier key descriptions that are returned by getTextDescription()

Definition at line 274 of file juce_KeyPress.cpp.

◆ isCurrentlyDown()

bool juce::KeyPress::isCurrentlyDown ( ) const

Checks whether the user is currently holding down the keys that make up this KeyPress.

Note that this will return false if any extra modifier keys are down - e.g. if the keypress is CTRL+X and the user is actually holding CTRL+ALT+x then it will be false.

Definition at line 59 of file juce_KeyPress.cpp.

◆ isKeyCode()

bool juce::KeyPress::isKeyCode ( int  keyCodeToCompare) const
noexcept

Checks whether the KeyPress's key is the same as the one provided, without checking the modifiers.

The values for key codes can either be one of the special constants defined in this class, or an 8-bit character code.

See also
getKeyCode

Definition at line 132 of file juce_KeyPress.h.

◆ isKeyCurrentlyDown()

bool juce::KeyPress::isKeyCurrentlyDown ( int  keyCode)
static

Checks whether a particular key is held down, irrespective of modifiers.

The values for key codes can either be one of the special constants defined in this class, or an 8-bit character code.

Definition at line 824 of file juce_Windowing_linux.cpp.

◆ isValid()

bool juce::KeyPress::isValid ( ) const
noexcept

Returns true if this is a valid KeyPress.

A null keypress can be created by the default constructor, in case it's needed.

Definition at line 102 of file juce_KeyPress.h.

◆ operator!=() [1/2]

bool juce::KeyPress::operator!= ( const KeyPress other) const
noexcept

Compares two KeyPress objects.

Definition at line 56 of file juce_KeyPress.cpp.

◆ operator!=() [2/2]

bool juce::KeyPress::operator!= ( int  keyCode) const
noexcept

Returns true if this keypress is not for the given keycode without any modifiers.

Definition at line 57 of file juce_KeyPress.cpp.

◆ operator==() [1/2]

bool juce::KeyPress::operator== ( const KeyPress other) const
noexcept

Compares two KeyPress objects.

Definition at line 43 of file juce_KeyPress.cpp.

◆ operator==() [2/2]

bool juce::KeyPress::operator== ( int  keyCode) const
noexcept

Returns true if this keypress is for the given keycode without any modifiers.

Definition at line 38 of file juce_KeyPress.cpp.

Member Data Documentation

◆ backspaceKey

const int juce::KeyPress::backspaceKey
static

key-code for the backspace key

Definition at line 195 of file juce_KeyPress.h.

◆ deleteKey

const int juce::KeyPress::deleteKey
static

key-code for the delete key (not backspace)

Definition at line 194 of file juce_KeyPress.h.

◆ downKey

const int juce::KeyPress::downKey
static

key-code for the cursor-down key

Definition at line 199 of file juce_KeyPress.h.

◆ endKey

const int juce::KeyPress::endKey
static

key-code for the end key

Definition at line 205 of file juce_KeyPress.h.

◆ escapeKey

const int juce::KeyPress::escapeKey
static

key-code for the escape key

Definition at line 190 of file juce_KeyPress.h.

◆ F10Key

const int juce::KeyPress::F10Key
static

key-code for the F10 key

Definition at line 216 of file juce_KeyPress.h.

◆ F11Key

const int juce::KeyPress::F11Key
static

key-code for the F11 key

Definition at line 217 of file juce_KeyPress.h.

◆ F12Key

const int juce::KeyPress::F12Key
static

key-code for the F12 key

Definition at line 218 of file juce_KeyPress.h.

◆ F13Key

const int juce::KeyPress::F13Key
static

key-code for the F13 key

Definition at line 219 of file juce_KeyPress.h.

◆ F14Key

const int juce::KeyPress::F14Key
static

key-code for the F14 key

Definition at line 220 of file juce_KeyPress.h.

◆ F15Key

const int juce::KeyPress::F15Key
static

key-code for the F15 key

Definition at line 221 of file juce_KeyPress.h.

◆ F16Key

const int juce::KeyPress::F16Key
static

key-code for the F16 key

Definition at line 222 of file juce_KeyPress.h.

◆ F17Key

const int juce::KeyPress::F17Key
static

key-code for the F17 key

Definition at line 223 of file juce_KeyPress.h.

◆ F18Key

const int juce::KeyPress::F18Key
static

key-code for the F18 key

Definition at line 224 of file juce_KeyPress.h.

◆ F19Key

const int juce::KeyPress::F19Key
static

key-code for the F19 key

Definition at line 225 of file juce_KeyPress.h.

◆ F1Key

const int juce::KeyPress::F1Key
static

key-code for the F1 key

Definition at line 207 of file juce_KeyPress.h.

◆ F20Key

const int juce::KeyPress::F20Key
static

key-code for the F20 key

Definition at line 226 of file juce_KeyPress.h.

◆ F21Key

const int juce::KeyPress::F21Key
static

key-code for the F21 key

Definition at line 227 of file juce_KeyPress.h.

◆ F22Key

const int juce::KeyPress::F22Key
static

key-code for the F22 key

Definition at line 228 of file juce_KeyPress.h.

◆ F23Key

const int juce::KeyPress::F23Key
static

key-code for the F23 key

Definition at line 229 of file juce_KeyPress.h.

◆ F24Key

const int juce::KeyPress::F24Key
static

key-code for the F24 key

Definition at line 230 of file juce_KeyPress.h.

◆ F25Key

const int juce::KeyPress::F25Key
static

key-code for the F25 key

Definition at line 231 of file juce_KeyPress.h.

◆ F26Key

const int juce::KeyPress::F26Key
static

key-code for the F26 key

Definition at line 232 of file juce_KeyPress.h.

◆ F27Key

const int juce::KeyPress::F27Key
static

key-code for the F27 key

Definition at line 233 of file juce_KeyPress.h.

◆ F28Key

const int juce::KeyPress::F28Key
static

key-code for the F28 key

Definition at line 234 of file juce_KeyPress.h.

◆ F29Key

const int juce::KeyPress::F29Key
static

key-code for the F29 key

Definition at line 235 of file juce_KeyPress.h.

◆ F2Key

const int juce::KeyPress::F2Key
static

key-code for the F2 key

Definition at line 208 of file juce_KeyPress.h.

◆ F30Key

const int juce::KeyPress::F30Key
static

key-code for the F30 key

Definition at line 236 of file juce_KeyPress.h.

◆ F31Key

const int juce::KeyPress::F31Key
static

key-code for the F31 key

Definition at line 237 of file juce_KeyPress.h.

◆ F32Key

const int juce::KeyPress::F32Key
static

key-code for the F32 key

Definition at line 238 of file juce_KeyPress.h.

◆ F33Key

const int juce::KeyPress::F33Key
static

key-code for the F33 key

Definition at line 239 of file juce_KeyPress.h.

◆ F34Key

const int juce::KeyPress::F34Key
static

key-code for the F34 key

Definition at line 240 of file juce_KeyPress.h.

◆ F35Key

const int juce::KeyPress::F35Key
static

key-code for the F35 key

Definition at line 241 of file juce_KeyPress.h.

◆ F3Key

const int juce::KeyPress::F3Key
static

key-code for the F3 key

Definition at line 209 of file juce_KeyPress.h.

◆ F4Key

const int juce::KeyPress::F4Key
static

key-code for the F4 key

Definition at line 210 of file juce_KeyPress.h.

◆ F5Key

const int juce::KeyPress::F5Key
static

key-code for the F5 key

Definition at line 211 of file juce_KeyPress.h.

◆ F6Key

const int juce::KeyPress::F6Key
static

key-code for the F6 key

Definition at line 212 of file juce_KeyPress.h.

◆ F7Key

const int juce::KeyPress::F7Key
static

key-code for the F7 key

Definition at line 213 of file juce_KeyPress.h.

◆ F8Key

const int juce::KeyPress::F8Key
static

key-code for the F8 key

Definition at line 214 of file juce_KeyPress.h.

◆ F9Key

const int juce::KeyPress::F9Key
static

key-code for the F9 key

Definition at line 215 of file juce_KeyPress.h.

◆ fastForwardKey

const int juce::KeyPress::fastForwardKey
static

key-code for a multimedia 'fast-forward' key, (not all keyboards will have one)

Definition at line 265 of file juce_KeyPress.h.

◆ homeKey

const int juce::KeyPress::homeKey
static

key-code for the home key

Definition at line 204 of file juce_KeyPress.h.

◆ insertKey

const int juce::KeyPress::insertKey
static

key-code for the insert key

Definition at line 196 of file juce_KeyPress.h.

◆ leftKey

const int juce::KeyPress::leftKey
static

key-code for the cursor-left key

Definition at line 200 of file juce_KeyPress.h.

◆ numberPad0

const int juce::KeyPress::numberPad0
static

key-code for the 0 on the numeric keypad.

Definition at line 243 of file juce_KeyPress.h.

◆ numberPad1

const int juce::KeyPress::numberPad1
static

key-code for the 1 on the numeric keypad.

Definition at line 244 of file juce_KeyPress.h.

◆ numberPad2

const int juce::KeyPress::numberPad2
static

key-code for the 2 on the numeric keypad.

Definition at line 245 of file juce_KeyPress.h.

◆ numberPad3

const int juce::KeyPress::numberPad3
static

key-code for the 3 on the numeric keypad.

Definition at line 246 of file juce_KeyPress.h.

◆ numberPad4

const int juce::KeyPress::numberPad4
static

key-code for the 4 on the numeric keypad.

Definition at line 247 of file juce_KeyPress.h.

◆ numberPad5

const int juce::KeyPress::numberPad5
static

key-code for the 5 on the numeric keypad.

Definition at line 248 of file juce_KeyPress.h.

◆ numberPad6

const int juce::KeyPress::numberPad6
static

key-code for the 6 on the numeric keypad.

Definition at line 249 of file juce_KeyPress.h.

◆ numberPad7

const int juce::KeyPress::numberPad7
static

key-code for the 7 on the numeric keypad.

Definition at line 250 of file juce_KeyPress.h.

◆ numberPad8

const int juce::KeyPress::numberPad8
static

key-code for the 8 on the numeric keypad.

Definition at line 251 of file juce_KeyPress.h.

◆ numberPad9

const int juce::KeyPress::numberPad9
static

key-code for the 9 on the numeric keypad.

Definition at line 252 of file juce_KeyPress.h.

◆ numberPadAdd

const int juce::KeyPress::numberPadAdd
static

key-code for the add sign on the numeric keypad.

Definition at line 254 of file juce_KeyPress.h.

◆ numberPadDecimalPoint

const int juce::KeyPress::numberPadDecimalPoint
static

key-code for the decimal point sign on the numeric keypad.

Definition at line 259 of file juce_KeyPress.h.

◆ numberPadDelete

const int juce::KeyPress::numberPadDelete
static

key-code for the delete key on the numeric keypad.

Definition at line 261 of file juce_KeyPress.h.

◆ numberPadDivide

const int juce::KeyPress::numberPadDivide
static

key-code for the divide sign on the numeric keypad.

Definition at line 257 of file juce_KeyPress.h.

◆ numberPadEquals

const int juce::KeyPress::numberPadEquals
static

key-code for the equals key on the numeric keypad.

Definition at line 260 of file juce_KeyPress.h.

◆ numberPadMultiply

const int juce::KeyPress::numberPadMultiply
static

key-code for the multiply sign on the numeric keypad.

Definition at line 256 of file juce_KeyPress.h.

◆ numberPadSeparator

const int juce::KeyPress::numberPadSeparator
static

key-code for the comma on the numeric keypad.

Definition at line 258 of file juce_KeyPress.h.

◆ numberPadSubtract

const int juce::KeyPress::numberPadSubtract
static

key-code for the subtract sign on the numeric keypad.

Definition at line 255 of file juce_KeyPress.h.

◆ pageDownKey

const int juce::KeyPress::pageDownKey
static

key-code for the page-down key

Definition at line 203 of file juce_KeyPress.h.

◆ pageUpKey

const int juce::KeyPress::pageUpKey
static

key-code for the page-up key

Definition at line 202 of file juce_KeyPress.h.

◆ playKey

const int juce::KeyPress::playKey
static

key-code for a multimedia 'play' key, (not all keyboards will have one)

Definition at line 263 of file juce_KeyPress.h.

◆ returnKey

const int juce::KeyPress::returnKey
static

key-code for the return key

Definition at line 191 of file juce_KeyPress.h.

◆ rewindKey

const int juce::KeyPress::rewindKey
static

key-code for a multimedia 'rewind' key, (not all keyboards will have one)

Definition at line 266 of file juce_KeyPress.h.

◆ rightKey

const int juce::KeyPress::rightKey
static

key-code for the cursor-right key

Definition at line 201 of file juce_KeyPress.h.

◆ spaceKey

const int juce::KeyPress::spaceKey
static

key-code for the space bar

Definition at line 189 of file juce_KeyPress.h.

◆ stopKey

const int juce::KeyPress::stopKey
static

key-code for a multimedia 'stop' key, (not all keyboards will have one)

Definition at line 264 of file juce_KeyPress.h.

◆ tabKey

const int juce::KeyPress::tabKey
static

key-code for the tab key

Definition at line 192 of file juce_KeyPress.h.

◆ upKey

const int juce::KeyPress::upKey
static

key-code for the cursor-up key

Definition at line 198 of file juce_KeyPress.h.


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