Represents a key press, including any modifier keys that are needed. More...
#include <juce_KeyPress.h>
Public Member Functions | |
KeyPress () noexcept | |
Creates an (invalid) KeyPress. More... | |
KeyPress (int keyCode, ModifierKeys modifiers, juce_wchar textCharacter) noexcept | |
Creates a KeyPress for a key and some modifiers. More... | |
KeyPress (int keyCode) noexcept | |
Creates a keypress with a keyCode but no modifiers or text character. More... | |
KeyPress (const KeyPress &other) noexcept | |
Creates a copy of another KeyPress. More... | |
int | getKeyCode () const noexcept |
Returns the key code itself. More... | |
ModifierKeys | getModifiers () const noexcept |
Returns the key modifiers. More... | |
juce_wchar | getTextCharacter () const noexcept |
Returns the character that is associated with this keypress. More... | |
String | getTextDescription () const |
Creates a textual description of the key combination. More... | |
String | getTextDescriptionWithIcons () const |
Creates a textual description of the key combination, using unicode icon symbols if possible. More... | |
bool | isCurrentlyDown () const |
Checks whether the user is currently holding down the keys that make up this KeyPress. More... | |
bool | isKeyCode (int keyCodeToCompare) const noexcept |
Checks whether the KeyPress's key is the same as the one provided, without checking the modifiers. More... | |
bool | isValid () const noexcept |
Returns true if this is a valid KeyPress. More... | |
bool | operator!= (const KeyPress &other) const noexcept |
Compares two KeyPress objects. More... | |
bool | operator!= (int keyCode) const noexcept |
Returns true if this keypress is not for the given keycode without any modifiers. More... | |
KeyPress & | operator= (const KeyPress &other) noexcept |
Copies this KeyPress from another one. More... | |
bool | operator== (const KeyPress &other) const noexcept |
Compares two KeyPress objects. More... | |
bool | operator== (int keyCode) const noexcept |
Returns true if this keypress is for the given keycode without any modifiers. More... | |
Static Public Member Functions | |
static KeyPress | createFromDescription (const String &textVersion) |
Converts a textual key description to a KeyPress. More... | |
static bool | isKeyCurrentlyDown (int keyCode) |
Checks whether a particular key is held down, irrespective of modifiers. More... | |
Static Public Attributes | |
static const int | backspaceKey |
key-code for the backspace key More... | |
static const int | deleteKey |
key-code for the delete key (not backspace) More... | |
static const int | downKey |
key-code for the cursor-down key More... | |
static const int | endKey |
key-code for the end key More... | |
static const int | escapeKey |
key-code for the escape key More... | |
static const int | F10Key |
key-code for the F10 key More... | |
static const int | F11Key |
key-code for the F11 key More... | |
static const int | F12Key |
key-code for the F12 key More... | |
static const int | F13Key |
key-code for the F13 key More... | |
static const int | F14Key |
key-code for the F14 key More... | |
static const int | F15Key |
key-code for the F15 key More... | |
static const int | F16Key |
key-code for the F16 key More... | |
static const int | F1Key |
key-code for the F1 key More... | |
static const int | F2Key |
key-code for the F2 key More... | |
static const int | F3Key |
key-code for the F3 key More... | |
static const int | F4Key |
key-code for the F4 key More... | |
static const int | F5Key |
key-code for the F5 key More... | |
static const int | F6Key |
key-code for the F6 key More... | |
static const int | F7Key |
key-code for the F7 key More... | |
static const int | F8Key |
key-code for the F8 key More... | |
static const int | F9Key |
key-code for the F9 key More... | |
static const int | fastForwardKey |
key-code for a multimedia 'fast-forward' key, (not all keyboards will have one) More... | |
static const int | homeKey |
key-code for the home key More... | |
static const int | insertKey |
key-code for the insert key More... | |
static const int | leftKey |
key-code for the cursor-left key More... | |
static const int | numberPad0 |
key-code for the 0 on the numeric keypad. More... | |
static const int | numberPad1 |
key-code for the 1 on the numeric keypad. More... | |
static const int | numberPad2 |
key-code for the 2 on the numeric keypad. More... | |
static const int | numberPad3 |
key-code for the 3 on the numeric keypad. More... | |
static const int | numberPad4 |
key-code for the 4 on the numeric keypad. More... | |
static const int | numberPad5 |
key-code for the 5 on the numeric keypad. More... | |
static const int | numberPad6 |
key-code for the 6 on the numeric keypad. More... | |
static const int | numberPad7 |
key-code for the 7 on the numeric keypad. More... | |
static const int | numberPad8 |
key-code for the 8 on the numeric keypad. More... | |
static const int | numberPad9 |
key-code for the 9 on the numeric keypad. More... | |
static const int | numberPadAdd |
key-code for the add sign on the numeric keypad. More... | |
static const int | numberPadDecimalPoint |
key-code for the decimal point sign on the numeric keypad. More... | |
static const int | numberPadDelete |
key-code for the delete key on the numeric keypad. More... | |
static const int | numberPadDivide |
key-code for the divide sign on the numeric keypad. More... | |
static const int | numberPadEquals |
key-code for the equals key on the numeric keypad. More... | |
static const int | numberPadMultiply |
key-code for the multiply sign on the numeric keypad. More... | |
static const int | numberPadSeparator |
key-code for the comma on the numeric keypad. More... | |
static const int | numberPadSubtract |
key-code for the subtract sign on the numeric keypad. More... | |
static const int | pageDownKey |
key-code for the page-down key More... | |
static const int | pageUpKey |
key-code for the page-up key More... | |
static const int | playKey |
key-code for a multimedia 'play' key, (not all keyboards will have one) More... | |
static const int | returnKey |
key-code for the return key More... | |
static const int | rewindKey |
key-code for a multimedia 'rewind' key, (not all keyboards will have one) More... | |
static const int | rightKey |
key-code for the cursor-right key More... | |
static const int | spaceKey |
key-code for the space bar More... | |
static const int | stopKey |
key-code for a multimedia 'stop' key, (not all keyboards will have one) More... | |
static const int | tabKey |
key-code for the tab key More... | |
static const int | upKey |
key-code for the cursor-up key More... | |
Private Attributes | |
int | keyCode |
ModifierKeys | mods |
juce_wchar | textCharacter |
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.
|
noexcept |
Creates a KeyPress for a key and some modifiers.
e.g. CTRL+C would be: KeyPress ('c', ModifierKeys::ctrlModifier) SHIFT+Escape would be: KeyPress (KeyPress::escapeKey, ModifierKeys::shiftModifier)
keyCode | a 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'. |
modifiers | the modifiers to associate with the keystroke |
textCharacter | the 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 |
|
explicitnoexcept |
Creates a keypress with a keyCode but no modifiers or text character.
Converts a textual key description to a KeyPress.
This attempts to decode a textual version of a keypress, e.g. "CTRL + C" or "SPACE".
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.
|
inlinenoexcept |
Returns the key code itself.
This will either be one of the special constants defined in this class, or an 8-bit character code.
|
inlinenoexcept |
Returns the key modifiers.
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
inlinenoexcept |
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.
String 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.
String 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()
bool 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.
|
inlinenoexcept |
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.
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
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.
|
inlinenoexcept |
Returns true if this is a valid KeyPress.
A null keypress can be created by the default constructor, in case it's needed.
|
noexcept |
Returns true if this keypress is not for the given keycode without any modifiers.
Copies this KeyPress from another one.
|
noexcept |
Returns true if this keypress is for the given keycode without any modifiers.
|
static |
key-code for the backspace key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the delete key (not backspace)
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the cursor-down key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the end key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the escape key
|
static |
key-code for the F10 key
|
static |
key-code for the F11 key
|
static |
key-code for the F12 key
|
static |
key-code for the F13 key
|
static |
key-code for the F14 key
|
static |
key-code for the F15 key
|
static |
key-code for the F16 key
|
static |
key-code for the F1 key
|
static |
key-code for the F2 key
|
static |
key-code for the F3 key
|
static |
key-code for the F4 key
|
static |
key-code for the F5 key
|
static |
key-code for the F6 key
|
static |
key-code for the F7 key
|
static |
key-code for the F8 key
|
static |
key-code for the F9 key
|
static |
key-code for a multimedia 'fast-forward' key, (not all keyboards will have one)
|
static |
key-code for the home key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the insert key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
private |
|
static |
key-code for the cursor-left key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
private |
|
static |
key-code for the 0 on the numeric keypad.
|
static |
key-code for the 1 on the numeric keypad.
|
static |
key-code for the 2 on the numeric keypad.
|
static |
key-code for the 3 on the numeric keypad.
|
static |
key-code for the 4 on the numeric keypad.
|
static |
key-code for the 5 on the numeric keypad.
|
static |
key-code for the 6 on the numeric keypad.
|
static |
key-code for the 7 on the numeric keypad.
|
static |
key-code for the 8 on the numeric keypad.
|
static |
key-code for the 9 on the numeric keypad.
|
static |
key-code for the add sign on the numeric keypad.
|
static |
key-code for the decimal point sign on the numeric keypad.
|
static |
key-code for the delete key on the numeric keypad.
|
static |
key-code for the divide sign on the numeric keypad.
|
static |
key-code for the equals key on the numeric keypad.
|
static |
key-code for the multiply sign on the numeric keypad.
|
static |
key-code for the comma on the numeric keypad.
|
static |
key-code for the subtract sign on the numeric keypad.
|
static |
key-code for the page-down key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the page-up key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for a multimedia 'play' key, (not all keyboards will have one)
|
static |
key-code for the return key
|
static |
key-code for a multimedia 'rewind' key, (not all keyboards will have one)
|
static |
key-code for the cursor-right key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
static |
key-code for the space bar
|
static |
key-code for a multimedia 'stop' key, (not all keyboards will have one)
|
static |
key-code for the tab key
|
private |
|
static |
key-code for the cursor-up key
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().