LMMS
Loading...
Searching...
No Matches
juce::KeyPress Class Reference

#include <juce_KeyPress.h>

Public Member Functions

 KeyPress ()=default
 ~KeyPress ()=default
 KeyPress (int keyCode, ModifierKeys modifiers, juce_wchar textCharacter) noexcept
 KeyPress (int keyCode) noexcept
 KeyPress (const KeyPress &)=default
KeyPressoperator= (const KeyPress &)=default
bool operator== (const KeyPress &other) const noexcept
bool operator!= (const KeyPress &other) const noexcept
bool operator== (int keyCode) const noexcept
bool operator!= (int keyCode) const noexcept
bool isValid () const noexcept
int getKeyCode () const noexcept
ModifierKeys getModifiers () const noexcept
juce_wchar getTextCharacter () const noexcept
bool isKeyCode (int keyCodeToCompare) const noexcept
String getTextDescription () const
String getTextDescriptionWithIcons () const
bool isCurrentlyDown () const

Static Public Member Functions

static KeyPress createFromDescription (const String &textVersion)
static bool isKeyCurrentlyDown (int keyCode)

Static Public Attributes

static const int spaceKey = VK_SPACE
static const int escapeKey = VK_ESCAPE
static const int returnKey = VK_RETURN
static const int tabKey = VK_TAB
static const int deleteKey = VK_DELETE | extendedKeyModifier
static const int backspaceKey = VK_BACK
static const int insertKey = VK_INSERT | extendedKeyModifier
static const int upKey = VK_UP | extendedKeyModifier
static const int downKey = VK_DOWN | extendedKeyModifier
static const int leftKey = VK_LEFT | extendedKeyModifier
static const int rightKey = VK_RIGHT | extendedKeyModifier
static const int pageUpKey = VK_PRIOR | extendedKeyModifier
static const int pageDownKey = VK_NEXT | extendedKeyModifier
static const int homeKey = VK_HOME | extendedKeyModifier
static const int endKey = VK_END | extendedKeyModifier
static const int F1Key = VK_F1 | extendedKeyModifier
static const int F2Key = VK_F2 | extendedKeyModifier
static const int F3Key = VK_F3 | extendedKeyModifier
static const int F4Key = VK_F4 | extendedKeyModifier
static const int F5Key = VK_F5 | extendedKeyModifier
static const int F6Key = VK_F6 | extendedKeyModifier
static const int F7Key = VK_F7 | extendedKeyModifier
static const int F8Key = VK_F8 | extendedKeyModifier
static const int F9Key = VK_F9 | extendedKeyModifier
static const int F10Key = VK_F10 | extendedKeyModifier
static const int F11Key = VK_F11 | extendedKeyModifier
static const int F12Key = VK_F12 | extendedKeyModifier
static const int F13Key = VK_F13 | extendedKeyModifier
static const int F14Key = VK_F14 | extendedKeyModifier
static const int F15Key = VK_F15 | extendedKeyModifier
static const int F16Key = VK_F16 | extendedKeyModifier
static const int F17Key = VK_F17 | extendedKeyModifier
static const int F18Key = VK_F18 | extendedKeyModifier
static const int F19Key = VK_F19 | extendedKeyModifier
static const int F20Key = VK_F20 | extendedKeyModifier
static const int F21Key = VK_F21 | extendedKeyModifier
static const int F22Key = VK_F22 | extendedKeyModifier
static const int F23Key = VK_F23 | extendedKeyModifier
static const int F24Key = VK_F24 | extendedKeyModifier
static const int F25Key = 0x31000
static const int F26Key = 0x31001
static const int F27Key = 0x31002
static const int F28Key = 0x31003
static const int F29Key = 0x31004
static const int F30Key = 0x31005
static const int F31Key = 0x31006
static const int F32Key = 0x31007
static const int F33Key = 0x31008
static const int F34Key = 0x31009
static const int F35Key = 0x3100a
static const int numberPad0 = VK_NUMPAD0 | extendedKeyModifier
static const int numberPad1 = VK_NUMPAD1 | extendedKeyModifier
static const int numberPad2 = VK_NUMPAD2 | extendedKeyModifier
static const int numberPad3 = VK_NUMPAD3 | extendedKeyModifier
static const int numberPad4 = VK_NUMPAD4 | extendedKeyModifier
static const int numberPad5 = VK_NUMPAD5 | extendedKeyModifier
static const int numberPad6 = VK_NUMPAD6 | extendedKeyModifier
static const int numberPad7 = VK_NUMPAD7 | extendedKeyModifier
static const int numberPad8 = VK_NUMPAD8 | extendedKeyModifier
static const int numberPad9 = VK_NUMPAD9 | extendedKeyModifier
static const int numberPadAdd = VK_ADD | extendedKeyModifier
static const int numberPadSubtract = VK_SUBTRACT | extendedKeyModifier
static const int numberPadMultiply = VK_MULTIPLY | extendedKeyModifier
static const int numberPadDivide = VK_DIVIDE | extendedKeyModifier
static const int numberPadSeparator = VK_SEPARATOR | extendedKeyModifier
static const int numberPadDecimalPoint = VK_DECIMAL | extendedKeyModifier
static const int numberPadEquals = 0x92 | extendedKeyModifier
static const int numberPadDelete = VK_DELETE | extendedKeyModifier
static const int playKey = 0x30000
static const int stopKey = 0x30001
static const int fastForwardKey = 0x30002
static const int rewindKey = 0x30003

Private Attributes

int keyCode = 0
ModifierKeys mods
juce_wchar textCharacter = 0

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}

Constructor & Destructor Documentation

◆ KeyPress() [1/4]

juce::KeyPress::KeyPress ( )
default

Creates an (invalid) KeyPress.

See also
isValid

◆ ~KeyPress()

juce::KeyPress::~KeyPress ( )
default

Destructor.

◆ KeyPress() [2/4]

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

◆ KeyPress() [3/4]

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

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

◆ KeyPress() [4/4]

juce::KeyPress::KeyPress ( const KeyPress & )
default

Creates a copy of another KeyPress.

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

◆ 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()

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

Returns the key modifiers.

See also
ModifierKeys

◆ 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 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.

◆ 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()

◆ 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.

◆ 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()

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]

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

Compares two KeyPress objects.

◆ 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.

◆ operator=()

KeyPress & juce::KeyPress::operator= ( const KeyPress & )
default

Copies this KeyPress from another one.

◆ operator==() [1/2]

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

Compares two KeyPress objects.

◆ operator==() [2/2]

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

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

Member Data Documentation

◆ backspaceKey

const int juce::KeyPress::backspaceKey = VK_BACK
static

key-code for the backspace key

◆ deleteKey

const int juce::KeyPress::deleteKey = VK_DELETE | extendedKeyModifier
static

key-code for the delete key (not backspace)

◆ downKey

const int juce::KeyPress::downKey = VK_DOWN | extendedKeyModifier
static

key-code for the cursor-down key

◆ endKey

const int juce::KeyPress::endKey = VK_END | extendedKeyModifier
static

key-code for the end key

◆ escapeKey

const int juce::KeyPress::escapeKey = VK_ESCAPE
static

key-code for the escape key

◆ F10Key

const int juce::KeyPress::F10Key = VK_F10 | extendedKeyModifier
static

key-code for the F10 key

◆ F11Key

const int juce::KeyPress::F11Key = VK_F11 | extendedKeyModifier
static

key-code for the F11 key

◆ F12Key

const int juce::KeyPress::F12Key = VK_F12 | extendedKeyModifier
static

key-code for the F12 key

◆ F13Key

const int juce::KeyPress::F13Key = VK_F13 | extendedKeyModifier
static

key-code for the F13 key

◆ F14Key

const int juce::KeyPress::F14Key = VK_F14 | extendedKeyModifier
static

key-code for the F14 key

◆ F15Key

const int juce::KeyPress::F15Key = VK_F15 | extendedKeyModifier
static

key-code for the F15 key

◆ F16Key

const int juce::KeyPress::F16Key = VK_F16 | extendedKeyModifier
static

key-code for the F16 key

◆ F17Key

const int juce::KeyPress::F17Key = VK_F17 | extendedKeyModifier
static

key-code for the F17 key

◆ F18Key

const int juce::KeyPress::F18Key = VK_F18 | extendedKeyModifier
static

key-code for the F18 key

◆ F19Key

const int juce::KeyPress::F19Key = VK_F19 | extendedKeyModifier
static

key-code for the F19 key

◆ F1Key

const int juce::KeyPress::F1Key = VK_F1 | extendedKeyModifier
static

key-code for the F1 key

◆ F20Key

const int juce::KeyPress::F20Key = VK_F20 | extendedKeyModifier
static

key-code for the F20 key

◆ F21Key

const int juce::KeyPress::F21Key = VK_F21 | extendedKeyModifier
static

key-code for the F21 key

◆ F22Key

const int juce::KeyPress::F22Key = VK_F22 | extendedKeyModifier
static

key-code for the F22 key

◆ F23Key

const int juce::KeyPress::F23Key = VK_F23 | extendedKeyModifier
static

key-code for the F23 key

◆ F24Key

const int juce::KeyPress::F24Key = VK_F24 | extendedKeyModifier
static

key-code for the F24 key

◆ F25Key

const int juce::KeyPress::F25Key = 0x31000
static

key-code for the F25 key

◆ F26Key

const int juce::KeyPress::F26Key = 0x31001
static

key-code for the F26 key

◆ F27Key

const int juce::KeyPress::F27Key = 0x31002
static

key-code for the F27 key

◆ F28Key

const int juce::KeyPress::F28Key = 0x31003
static

key-code for the F28 key

◆ F29Key

const int juce::KeyPress::F29Key = 0x31004
static

key-code for the F29 key

◆ F2Key

const int juce::KeyPress::F2Key = VK_F2 | extendedKeyModifier
static

key-code for the F2 key

◆ F30Key

const int juce::KeyPress::F30Key = 0x31005
static

key-code for the F30 key

◆ F31Key

const int juce::KeyPress::F31Key = 0x31006
static

key-code for the F31 key

◆ F32Key

const int juce::KeyPress::F32Key = 0x31007
static

key-code for the F32 key

◆ F33Key

const int juce::KeyPress::F33Key = 0x31008
static

key-code for the F33 key

◆ F34Key

const int juce::KeyPress::F34Key = 0x31009
static

key-code for the F34 key

◆ F35Key

const int juce::KeyPress::F35Key = 0x3100a
static

key-code for the F35 key

◆ F3Key

const int juce::KeyPress::F3Key = VK_F3 | extendedKeyModifier
static

key-code for the F3 key

◆ F4Key

const int juce::KeyPress::F4Key = VK_F4 | extendedKeyModifier
static

key-code for the F4 key

◆ F5Key

const int juce::KeyPress::F5Key = VK_F5 | extendedKeyModifier
static

key-code for the F5 key

◆ F6Key

const int juce::KeyPress::F6Key = VK_F6 | extendedKeyModifier
static

key-code for the F6 key

◆ F7Key

const int juce::KeyPress::F7Key = VK_F7 | extendedKeyModifier
static

key-code for the F7 key

◆ F8Key

const int juce::KeyPress::F8Key = VK_F8 | extendedKeyModifier
static

key-code for the F8 key

◆ F9Key

const int juce::KeyPress::F9Key = VK_F9 | extendedKeyModifier
static

key-code for the F9 key

◆ fastForwardKey

const int juce::KeyPress::fastForwardKey = 0x30002
static

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

◆ homeKey

const int juce::KeyPress::homeKey = VK_HOME | extendedKeyModifier
static

key-code for the home key

◆ insertKey

const int juce::KeyPress::insertKey = VK_INSERT | extendedKeyModifier
static

key-code for the insert key

◆ keyCode

int juce::KeyPress::keyCode = 0
private

◆ leftKey

const int juce::KeyPress::leftKey = VK_LEFT | extendedKeyModifier
static

key-code for the cursor-left key

◆ mods

ModifierKeys juce::KeyPress::mods
private

◆ numberPad0

const int juce::KeyPress::numberPad0 = VK_NUMPAD0 | extendedKeyModifier
static

key-code for the 0 on the numeric keypad.

◆ numberPad1

const int juce::KeyPress::numberPad1 = VK_NUMPAD1 | extendedKeyModifier
static

key-code for the 1 on the numeric keypad.

◆ numberPad2

const int juce::KeyPress::numberPad2 = VK_NUMPAD2 | extendedKeyModifier
static

key-code for the 2 on the numeric keypad.

◆ numberPad3

const int juce::KeyPress::numberPad3 = VK_NUMPAD3 | extendedKeyModifier
static

key-code for the 3 on the numeric keypad.

◆ numberPad4

const int juce::KeyPress::numberPad4 = VK_NUMPAD4 | extendedKeyModifier
static

key-code for the 4 on the numeric keypad.

◆ numberPad5

const int juce::KeyPress::numberPad5 = VK_NUMPAD5 | extendedKeyModifier
static

key-code for the 5 on the numeric keypad.

◆ numberPad6

const int juce::KeyPress::numberPad6 = VK_NUMPAD6 | extendedKeyModifier
static

key-code for the 6 on the numeric keypad.

◆ numberPad7

const int juce::KeyPress::numberPad7 = VK_NUMPAD7 | extendedKeyModifier
static

key-code for the 7 on the numeric keypad.

◆ numberPad8

const int juce::KeyPress::numberPad8 = VK_NUMPAD8 | extendedKeyModifier
static

key-code for the 8 on the numeric keypad.

◆ numberPad9

const int juce::KeyPress::numberPad9 = VK_NUMPAD9 | extendedKeyModifier
static

key-code for the 9 on the numeric keypad.

◆ numberPadAdd

const int juce::KeyPress::numberPadAdd = VK_ADD | extendedKeyModifier
static

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

◆ numberPadDecimalPoint

const int juce::KeyPress::numberPadDecimalPoint = VK_DECIMAL | extendedKeyModifier
static

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

◆ numberPadDelete

const int juce::KeyPress::numberPadDelete = VK_DELETE | extendedKeyModifier
static

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

◆ numberPadDivide

const int juce::KeyPress::numberPadDivide = VK_DIVIDE | extendedKeyModifier
static

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

◆ numberPadEquals

const int juce::KeyPress::numberPadEquals = 0x92 | extendedKeyModifier
static

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

◆ numberPadMultiply

const int juce::KeyPress::numberPadMultiply = VK_MULTIPLY | extendedKeyModifier
static

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

◆ numberPadSeparator

const int juce::KeyPress::numberPadSeparator = VK_SEPARATOR | extendedKeyModifier
static

key-code for the comma on the numeric keypad.

◆ numberPadSubtract

const int juce::KeyPress::numberPadSubtract = VK_SUBTRACT | extendedKeyModifier
static

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

◆ pageDownKey

const int juce::KeyPress::pageDownKey = VK_NEXT | extendedKeyModifier
static

key-code for the page-down key

◆ pageUpKey

const int juce::KeyPress::pageUpKey = VK_PRIOR | extendedKeyModifier
static

key-code for the page-up key

◆ playKey

const int juce::KeyPress::playKey = 0x30000
static

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

◆ returnKey

const int juce::KeyPress::returnKey = VK_RETURN
static

key-code for the return key

◆ rewindKey

const int juce::KeyPress::rewindKey = 0x30003
static

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

◆ rightKey

const int juce::KeyPress::rightKey = VK_RIGHT | extendedKeyModifier
static

key-code for the cursor-right key

◆ spaceKey

const int juce::KeyPress::spaceKey = VK_SPACE
static

key-code for the space bar

◆ stopKey

const int juce::KeyPress::stopKey = 0x30001
static

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

◆ tabKey

const int juce::KeyPress::tabKey = VK_TAB
static

key-code for the tab key

◆ textCharacter

juce_wchar juce::KeyPress::textCharacter = 0
private

◆ upKey

const int juce::KeyPress::upKey = VK_UP | extendedKeyModifier
static

key-code for the cursor-up key


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