#include <juce_gui_basics.h>
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
◆ KeyPress() [1/4]
◆ KeyPress() [2/4]
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)
- Parameters
-
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 |
- See also
- getKeyCode, isKeyCode, getModifiers
◆ KeyPress() [3/4]
KeyPress::KeyPress |
( |
int |
keyCode | ) |
|
|
explicitnoexcept |
Creates a keypress with a keyCode but no modifiers or text character.
◆ KeyPress() [4/4]
◆ createFromDescription()
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.
- See also
- getTextDescription
◆ getKeyCode()
int juce::KeyPress::getKeyCode |
( |
| ) |
const |
|
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.
◆ getModifiers()
◆ getTextCharacter()
juce_wchar juce::KeyPress::getTextCharacter |
( |
| ) |
const |
|
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.
◆ getTextDescription()
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.
◆ getTextDescriptionWithIcons()
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()
◆ isCurrentlyDown()
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.
◆ isKeyCode()
bool juce::KeyPress::isKeyCode |
( |
int |
keyCodeToCompare | ) |
const |
|
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.
- See also
- getKeyCode
◆ isKeyCurrentlyDown()
static 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.
◆ isValid()
bool juce::KeyPress::isValid |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if this is a valid KeyPress.
A null keypress can be created by the default constructor, in case it's needed.
◆ operator!=() [1/2]
◆ operator!=() [2/2]
bool KeyPress::operator!= |
( |
int |
keyCode | ) |
const |
|
noexcept |
Returns true if this keypress is not for the given keycode without any modifiers.
◆ operator=()
◆ operator==() [1/2]
◆ operator==() [2/2]
bool KeyPress::operator== |
( |
int |
keyCode | ) |
const |
|
noexcept |
Returns true if this keypress is for the given keycode without any modifiers.
◆ backspaceKey
const int juce::KeyPress::backspaceKey |
|
static |
key-code for the backspace key
◆ deleteKey
const int juce::KeyPress::deleteKey |
|
static |
key-code for the delete key (not backspace)
◆ downKey
const int juce::KeyPress::downKey |
|
static |
key-code for the cursor-down key
◆ endKey
const int juce::KeyPress::endKey |
|
static |
◆ escapeKey
const int juce::KeyPress::escapeKey |
|
static |
key-code for the escape key
◆ F10Key
const int juce::KeyPress::F10Key |
|
static |
◆ F11Key
const int juce::KeyPress::F11Key |
|
static |
◆ F12Key
const int juce::KeyPress::F12Key |
|
static |
◆ F13Key
const int juce::KeyPress::F13Key |
|
static |
◆ F14Key
const int juce::KeyPress::F14Key |
|
static |
◆ F15Key
const int juce::KeyPress::F15Key |
|
static |
◆ F16Key
const int juce::KeyPress::F16Key |
|
static |
◆ F1Key
const int juce::KeyPress::F1Key |
|
static |
◆ F2Key
const int juce::KeyPress::F2Key |
|
static |
◆ F3Key
const int juce::KeyPress::F3Key |
|
static |
◆ F4Key
const int juce::KeyPress::F4Key |
|
static |
◆ F5Key
const int juce::KeyPress::F5Key |
|
static |
◆ F6Key
const int juce::KeyPress::F6Key |
|
static |
◆ F7Key
const int juce::KeyPress::F7Key |
|
static |
◆ F8Key
const int juce::KeyPress::F8Key |
|
static |
◆ F9Key
const int juce::KeyPress::F9Key |
|
static |
◆ fastForwardKey
const int juce::KeyPress::fastForwardKey |
|
static |
key-code for a multimedia 'fast-forward' key, (not all keyboards will have one)
◆ homeKey
const int juce::KeyPress::homeKey |
|
static |
key-code for the home key
◆ insertKey
const int juce::KeyPress::insertKey |
|
static |
key-code for the insert key
◆ leftKey
const int juce::KeyPress::leftKey |
|
static |
key-code for the cursor-left key
◆ numberPad0
const int juce::KeyPress::numberPad0 |
|
static |
key-code for the 0 on the numeric keypad.
◆ numberPad1
const int juce::KeyPress::numberPad1 |
|
static |
key-code for the 1 on the numeric keypad.
◆ numberPad2
const int juce::KeyPress::numberPad2 |
|
static |
key-code for the 2 on the numeric keypad.
◆ numberPad3
const int juce::KeyPress::numberPad3 |
|
static |
key-code for the 3 on the numeric keypad.
◆ numberPad4
const int juce::KeyPress::numberPad4 |
|
static |
key-code for the 4 on the numeric keypad.
◆ numberPad5
const int juce::KeyPress::numberPad5 |
|
static |
key-code for the 5 on the numeric keypad.
◆ numberPad6
const int juce::KeyPress::numberPad6 |
|
static |
key-code for the 6 on the numeric keypad.
◆ numberPad7
const int juce::KeyPress::numberPad7 |
|
static |
key-code for the 7 on the numeric keypad.
◆ numberPad8
const int juce::KeyPress::numberPad8 |
|
static |
key-code for the 8 on the numeric keypad.
◆ numberPad9
const int juce::KeyPress::numberPad9 |
|
static |
key-code for the 9 on the numeric keypad.
◆ numberPadAdd
const int juce::KeyPress::numberPadAdd |
|
static |
key-code for the add sign on the numeric keypad.
◆ numberPadDecimalPoint
const int juce::KeyPress::numberPadDecimalPoint |
|
static |
key-code for the decimal point sign on the numeric keypad.
◆ numberPadDelete
const int juce::KeyPress::numberPadDelete |
|
static |
key-code for the delete key on the numeric keypad.
◆ numberPadDivide
const int juce::KeyPress::numberPadDivide |
|
static |
key-code for the divide sign on the numeric keypad.
◆ numberPadEquals
const int juce::KeyPress::numberPadEquals |
|
static |
key-code for the equals key on the numeric keypad.
◆ numberPadMultiply
const int juce::KeyPress::numberPadMultiply |
|
static |
key-code for the multiply sign on the numeric keypad.
◆ numberPadSeparator
const int juce::KeyPress::numberPadSeparator |
|
static |
key-code for the comma on the numeric keypad.
◆ numberPadSubtract
const int juce::KeyPress::numberPadSubtract |
|
static |
key-code for the subtract sign on the numeric keypad.
◆ pageDownKey
const int juce::KeyPress::pageDownKey |
|
static |
key-code for the page-down key
◆ pageUpKey
const int juce::KeyPress::pageUpKey |
|
static |
key-code for the page-up key
◆ playKey
const int juce::KeyPress::playKey |
|
static |
key-code for a multimedia 'play' key, (not all keyboards will have one)
◆ returnKey
const int juce::KeyPress::returnKey |
|
static |
key-code for the return key
◆ rewindKey
const int juce::KeyPress::rewindKey |
|
static |
key-code for a multimedia 'rewind' key, (not all keyboards will have one)
◆ rightKey
const int juce::KeyPress::rightKey |
|
static |
key-code for the cursor-right key
◆ spaceKey
const int juce::KeyPress::spaceKey |
|
static |
key-code for the space bar
◆ stopKey
const int juce::KeyPress::stopKey |
|
static |
key-code for a multimedia 'stop' key, (not all keyboards will have one)
◆ tabKey
const int juce::KeyPress::tabKey |
|
static |
◆ upKey
const int juce::KeyPress::upKey |
|
static |
key-code for the cursor-up key
The documentation for this class was generated from the following files: