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
juce_KeyPress.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
39class JUCE_API KeyPress
40{
41public:
42 //==============================================================================
47 KeyPress() = default;
48
50 ~KeyPress() = default;
51
71 KeyPress (int keyCode,
72 ModifierKeys modifiers,
73 juce_wchar textCharacter) noexcept;
74
76 explicit KeyPress (int keyCode) noexcept;
77
79 KeyPress (const KeyPress&) = default;
80
82 KeyPress& operator= (const KeyPress&) = default;
83
85 bool operator== (const KeyPress& other) const noexcept;
86
88 bool operator!= (const KeyPress& other) const noexcept;
89
91 bool operator== (int keyCode) const noexcept;
92
94 bool operator!= (int keyCode) const noexcept;
95
96 //==============================================================================
102 bool isValid() const noexcept { return keyCode != 0; }
103
109 int getKeyCode() const noexcept { return keyCode; }
110
115 ModifierKeys getModifiers() const noexcept { return mods; }
116
122 juce_wchar getTextCharacter() const noexcept { return textCharacter; }
123
132 bool isKeyCode (int keyCodeToCompare) const noexcept { return keyCode == keyCodeToCompare; }
133
134 //==============================================================================
146 static KeyPress createFromDescription (const String& textVersion);
147
155 String getTextDescription() const;
156
162 String getTextDescriptionWithIcons() const;
163
164 //==============================================================================
172 bool isCurrentlyDown() const;
173
179 static bool isKeyCurrentlyDown (int keyCode);
180
181 //==============================================================================
182 // Key codes
183 //
184 // Note that the actual values of these are platform-specific and may change
185 // without warning, so don't store them anywhere as constants. For persisting/retrieving
186 // KeyPress objects, use getTextDescription() and createFromDescription() instead.
187 //
188
189 static const int spaceKey;
190 static const int escapeKey;
191 static const int returnKey;
192 static const int tabKey;
194 static const int deleteKey;
195 static const int backspaceKey;
196 static const int insertKey;
198 static const int upKey;
199 static const int downKey;
200 static const int leftKey;
201 static const int rightKey;
202 static const int pageUpKey;
203 static const int pageDownKey;
204 static const int homeKey;
205 static const int endKey;
207 static const int F1Key;
208 static const int F2Key;
209 static const int F3Key;
210 static const int F4Key;
211 static const int F5Key;
212 static const int F6Key;
213 static const int F7Key;
214 static const int F8Key;
215 static const int F9Key;
216 static const int F10Key;
217 static const int F11Key;
218 static const int F12Key;
219 static const int F13Key;
220 static const int F14Key;
221 static const int F15Key;
222 static const int F16Key;
223 static const int F17Key;
224 static const int F18Key;
225 static const int F19Key;
226 static const int F20Key;
227 static const int F21Key;
228 static const int F22Key;
229 static const int F23Key;
230 static const int F24Key;
231 static const int F25Key;
232 static const int F26Key;
233 static const int F27Key;
234 static const int F28Key;
235 static const int F29Key;
236 static const int F30Key;
237 static const int F31Key;
238 static const int F32Key;
239 static const int F33Key;
240 static const int F34Key;
241 static const int F35Key;
243 static const int numberPad0;
244 static const int numberPad1;
245 static const int numberPad2;
246 static const int numberPad3;
247 static const int numberPad4;
248 static const int numberPad5;
249 static const int numberPad6;
250 static const int numberPad7;
251 static const int numberPad8;
252 static const int numberPad9;
254 static const int numberPadAdd;
255 static const int numberPadSubtract;
256 static const int numberPadMultiply;
257 static const int numberPadDivide;
258 static const int numberPadSeparator;
259 static const int numberPadDecimalPoint;
260 static const int numberPadEquals;
261 static const int numberPadDelete;
263 static const int playKey;
264 static const int stopKey;
265 static const int fastForwardKey;
266 static const int rewindKey;
268private:
269 //==============================================================================
270 int keyCode = 0;
271 ModifierKeys mods;
272 juce_wchar textCharacter = 0;
273
275};
276
277} // namespace juce
Represents a key press, including any modifier keys that are needed.
static const int numberPadMultiply
key-code for the multiply sign on the numeric keypad.
static const int F32Key
key-code for the F32 key
static const int numberPad8
key-code for the 8 on the numeric keypad.
static const int playKey
key-code for a multimedia 'play' key, (not all keyboards will have one)
static const int numberPad6
key-code for the 6 on the numeric keypad.
static const int F35Key
key-code for the F35 key
static const int F9Key
key-code for the F9 key
static const int F14Key
key-code for the F14 key
static const int F11Key
key-code for the F11 key
static const int homeKey
key-code for the home key
static const int numberPad2
key-code for the 2 on the numeric keypad.
static const int numberPad4
key-code for the 4 on the numeric keypad.
static const int F24Key
key-code for the F24 key
static const int numberPadEquals
key-code for the equals key on the numeric keypad.
static const int upKey
key-code for the cursor-up key
KeyPress()=default
Creates an (invalid) KeyPress.
static const int numberPad7
key-code for the 7 on the numeric keypad.
static const int F16Key
key-code for the F16 key
static const int F19Key
key-code for the F19 key
static const int fastForwardKey
key-code for a multimedia 'fast-forward' key, (not all keyboards will have one)
static const int F20Key
key-code for the F20 key
static const int stopKey
key-code for a multimedia 'stop' key, (not all keyboards will have one)
static const int numberPadSeparator
key-code for the comma on the numeric keypad.
static const int numberPad5
key-code for the 5 on the numeric keypad.
static const int F6Key
key-code for the F6 key
static const int endKey
key-code for the end key
static const int F1Key
key-code for the F1 key
static const int tabKey
key-code for the tab key
static const int F21Key
key-code for the F21 key
static const int numberPad0
key-code for the 0 on the numeric keypad.
juce_wchar getTextCharacter() const noexcept
Returns the character that is associated with this keypress.
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 F33Key
key-code for the F33 key
bool isKeyCode(int keyCodeToCompare) const noexcept
Checks whether the KeyPress's key is the same as the one provided, without checking the modifiers.
static const int rightKey
key-code for the cursor-right key
static const int F17Key
key-code for the F17 key
static const int rewindKey
key-code for a multimedia 'rewind' key, (not all keyboards will have one)
static const int F27Key
key-code for the F27 key
static const int deleteKey
key-code for the delete key (not backspace)
bool isValid() const noexcept
Returns true if this is a valid KeyPress.
static const int insertKey
key-code for the insert key
static const int F31Key
key-code for the F31 key
static const int F4Key
key-code for the F4 key
static const int F2Key
key-code for the F2 key
static const int F7Key
key-code for the F7 key
static const int F25Key
key-code for the F25 key
static const int F30Key
key-code for the F30 key
static const int F5Key
key-code for the F5 key
static const int F8Key
key-code for the F8 key
static const int F22Key
key-code for the F22 key
ModifierKeys getModifiers() const noexcept
Returns the key modifiers.
static const int F10Key
key-code for the F10 key
KeyPress(const KeyPress &)=default
Creates a copy of another KeyPress.
static const int downKey
key-code for the cursor-down key
static const int numberPadDelete
key-code for the delete key on the numeric keypad.
int getKeyCode() const noexcept
Returns the key code itself.
static const int numberPad3
key-code for the 3 on the numeric keypad.
static const int F15Key
key-code for the F15 key
static const int spaceKey
key-code for the space bar
static const int F3Key
key-code for the F3 key
static const int F13Key
key-code for the F13 key
static const int F26Key
key-code for the F26 key
static const int escapeKey
key-code for the escape key
static const int numberPadDivide
key-code for the divide sign on the numeric keypad.
static const int returnKey
key-code for the return key
static const int F23Key
key-code for the F23 key
static const int F29Key
key-code for the F29 key
static const int leftKey
key-code for the cursor-left key
static const int F34Key
key-code for the F34 key
~KeyPress()=default
Destructor.
static const int F12Key
key-code for the F12 key
static const int F18Key
key-code for the F18 key
static const int pageUpKey
key-code for the page-up key
static const int F28Key
key-code for the F28 key
static const int pageDownKey
key-code for the page-down key
static const int numberPad1
key-code for the 1 on the numeric keypad.
static const int numberPadDecimalPoint
key-code for the decimal point sign on the numeric keypad.
static const int backspaceKey
key-code for the backspace key
static const int numberPadSubtract
key-code for the subtract sign on the numeric keypad.
Represents the state of the mouse buttons and modifier keys.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
JUCE Namespace.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.