Loading...
Searching...
No Matches
Keyboard.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
31
32
33namespace sf
34{
35class String;
36
41namespace Keyboard
42{
156
161// NOLINTNEXTLINE(readability-identifier-naming)
162static constexpr unsigned int KeyCount{static_cast<unsigned int>(Key::Pause) + 1};
163
172enum class Scan
173{
174 Unknown = -1,
175 A = 0,
220 // For US keyboards mapped to key 29 (Microsoft Keyboard Scan Code Specification)
221 // For Non-US keyboards mapped to key 42 (Microsoft Keyboard Scan Code Specification)
222 // Typical language mappings: Belg:£µ` FrCa:<>} Dan:*' Dutch:`´ Fren:µ* Ger:'# Ital:§ù LatAm:[}` Nor:*@ Span:ç} Swed:*' Swiss:$£} UK:~# Brazil:}]
286 // For US keyboards doesn't exist
287 // For Non-US keyboards mapped to key 45 (Microsoft Keyboard Scan Code Specification)
288 // Typical language mappings: Belg:<> FrCa:«°» Dan:<> Dutch:]|[ Fren:<> Ger:<|> Ital:<> LatAm:<> Nor:<> Span:<> Swed:<|> Swiss:<> UK:\| Brazil: \|.
327};
328
330
335// NOLINTNEXTLINE(readability-identifier-naming)
336static constexpr unsigned int ScancodeCount{static_cast<unsigned int>(Scan::LaunchMediaSelect) + 1};
337
349[[nodiscard]] SFML_WINDOW_API bool isKeyPressed(Key key);
350
362[[nodiscard]] SFML_WINDOW_API bool isKeyPressed(Scancode code);
363
378
393
416
431} // namespace Keyboard
432
433} // namespace sf
434
435
#define SFML_WINDOW_API
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:89
Give access to the real-time state of the keyboard.
Definition Keyboard.hpp:42
Key localize(Scancode code)
Localize a physical key to a logical one.
static constexpr unsigned int KeyCount
The total number of keyboard keys, ignoring Key::Unknown
Definition Keyboard.hpp:162
static constexpr unsigned int ScancodeCount
The total number of scancodes, ignoring Scan::Unknown
Definition Keyboard.hpp:336
Scancode delocalize(Key key)
Identify the physical key corresponding to a logical one.
String getDescription(Scancode code)
Provide a string representation for a given scancode.
void setVirtualKeyboardVisible(bool visible)
Show or hide the virtual keyboard.
Key
Key codes.
Definition Keyboard.hpp:52
@ Escape
The Escape key.
Definition Keyboard.hpp:90
@ X
The X key.
Definition Keyboard.hpp:77
@ Num6
The 6 key.
Definition Keyboard.hpp:86
@ RAlt
The right Alt key.
Definition Keyboard.hpp:97
@ Down
Down arrow.
Definition Keyboard.hpp:128
@ Divide
The / key.
Definition Keyboard.hpp:124
@ C
The C key.
Definition Keyboard.hpp:56
@ Pause
The Pause key.
Definition Keyboard.hpp:154
@ Numpad9
The numpad 9 key.
Definition Keyboard.hpp:138
@ LBracket
The [ key.
Definition Keyboard.hpp:100
@ Period
The . key.
Definition Keyboard.hpp:104
@ Numpad0
The numpad 0 key.
Definition Keyboard.hpp:129
@ Subtract
The - key (minus, usually from numpad)
Definition Keyboard.hpp:122
@ F6
The F6 key.
Definition Keyboard.hpp:144
@ Z
The Z key.
Definition Keyboard.hpp:79
@ F14
The F14 key.
Definition Keyboard.hpp:152
@ RSystem
The right OS specific key: window (Windows and Linux), apple (macOS), ...
Definition Keyboard.hpp:98
@ Slash
The / key.
Definition Keyboard.hpp:106
@ F5
The F5 key.
Definition Keyboard.hpp:143
@ E
The E key.
Definition Keyboard.hpp:58
@ Numpad7
The numpad 7 key.
Definition Keyboard.hpp:136
@ P
The P key.
Definition Keyboard.hpp:69
@ F7
The F7 key.
Definition Keyboard.hpp:145
@ F8
The F8 key.
Definition Keyboard.hpp:146
@ Num7
The 7 key.
Definition Keyboard.hpp:87
@ F3
The F3 key.
Definition Keyboard.hpp:141
@ U
The U key.
Definition Keyboard.hpp:74
@ Numpad6
The numpad 6 key.
Definition Keyboard.hpp:135
@ Numpad4
The numpad 4 key.
Definition Keyboard.hpp:133
@ V
The V key.
Definition Keyboard.hpp:75
@ Y
The Y key.
Definition Keyboard.hpp:78
@ Comma
The , key.
Definition Keyboard.hpp:103
@ Tab
The Tabulation key.
Definition Keyboard.hpp:114
@ S
The S key.
Definition Keyboard.hpp:72
@ Numpad3
The numpad 3 key.
Definition Keyboard.hpp:132
@ W
The W key.
Definition Keyboard.hpp:76
@ Numpad5
The numpad 5 key.
Definition Keyboard.hpp:134
@ F11
The F11 key.
Definition Keyboard.hpp:149
@ LShift
The left Shift key.
Definition Keyboard.hpp:92
@ M
The M key.
Definition Keyboard.hpp:66
@ Hyphen
The - key (hyphen)
Definition Keyboard.hpp:110
@ Num2
The 2 key.
Definition Keyboard.hpp:82
@ Num5
The 5 key.
Definition Keyboard.hpp:85
@ A
The A key.
Definition Keyboard.hpp:54
@ F
The F key.
Definition Keyboard.hpp:59
@ Num0
The 0 key.
Definition Keyboard.hpp:80
@ End
The End key.
Definition Keyboard.hpp:117
@ Unknown
Unhandled key.
Definition Keyboard.hpp:53
@ F9
The F9 key.
Definition Keyboard.hpp:147
@ Num8
The 8 key.
Definition Keyboard.hpp:88
@ Numpad8
The numpad 8 key.
Definition Keyboard.hpp:137
@ Home
The Home key.
Definition Keyboard.hpp:118
@ N
The N key.
Definition Keyboard.hpp:67
@ RShift
The right Shift key.
Definition Keyboard.hpp:96
@ Right
Right arrow.
Definition Keyboard.hpp:126
@ Left
Left arrow.
Definition Keyboard.hpp:125
@ F13
The F13 key.
Definition Keyboard.hpp:151
@ Semicolon
The ; key.
Definition Keyboard.hpp:102
@ PageUp
The Page up key.
Definition Keyboard.hpp:115
@ B
The B key.
Definition Keyboard.hpp:55
@ LControl
The left Control key.
Definition Keyboard.hpp:91
@ Num3
The 3 key.
Definition Keyboard.hpp:83
@ Insert
The Insert key.
Definition Keyboard.hpp:119
@ K
The K key.
Definition Keyboard.hpp:64
@ LAlt
The left Alt key.
Definition Keyboard.hpp:93
@ RControl
The right Control key.
Definition Keyboard.hpp:95
@ F10
The F10 key.
Definition Keyboard.hpp:148
@ Menu
The Menu key.
Definition Keyboard.hpp:99
@ Apostrophe
The ' key.
Definition Keyboard.hpp:105
@ T
The T key.
Definition Keyboard.hpp:73
@ Num1
The 1 key.
Definition Keyboard.hpp:81
@ H
The H key.
Definition Keyboard.hpp:61
@ RBracket
The ] key.
Definition Keyboard.hpp:101
@ Numpad1
The numpad 1 key.
Definition Keyboard.hpp:130
@ Backspace
The Backspace key.
Definition Keyboard.hpp:113
@ L
The L key.
Definition Keyboard.hpp:65
@ Space
The Space key.
Definition Keyboard.hpp:111
@ Num9
The 9 key.
Definition Keyboard.hpp:89
@ I
The I key.
Definition Keyboard.hpp:62
@ G
The G key.
Definition Keyboard.hpp:60
@ Num4
The 4 key.
Definition Keyboard.hpp:84
@ F1
The F1 key.
Definition Keyboard.hpp:139
@ R
The R key.
Definition Keyboard.hpp:71
@ Multiply
The * key.
Definition Keyboard.hpp:123
@ F15
The F15 key.
Definition Keyboard.hpp:153
@ F4
The F4 key.
Definition Keyboard.hpp:142
@ F12
The F12 key.
Definition Keyboard.hpp:150
@ Add
The + key.
Definition Keyboard.hpp:121
@ Grave
The ` key.
Definition Keyboard.hpp:108
@ PageDown
The Page down key.
Definition Keyboard.hpp:116
@ Q
The Q key.
Definition Keyboard.hpp:70
@ Enter
The Enter/Return keys.
Definition Keyboard.hpp:112
@ O
The O key.
Definition Keyboard.hpp:68
@ Delete
The Delete key.
Definition Keyboard.hpp:120
@ Equal
The = key.
Definition Keyboard.hpp:109
@ D
The D key.
Definition Keyboard.hpp:57
@ Backslash
The \ key.
Definition Keyboard.hpp:107
@ Numpad2
The numpad 2 key.
Definition Keyboard.hpp:131
@ LSystem
The left OS specific key: window (Windows and Linux), apple (macOS), ...
Definition Keyboard.hpp:94
@ F2
The F2 key.
Definition Keyboard.hpp:140
@ J
The J key.
Definition Keyboard.hpp:63
bool isKeyPressed(Key key)
Check if a key is pressed.
Scan
Scancodes.
Definition Keyboard.hpp:173
@ LaunchMediaSelect
Keyboard Launch Media Select key.
Definition Keyboard.hpp:326
@ Back
Keyboard Back key.
Definition Keyboard.hpp:316
@ Stop
Keyboard Stop key.
Definition Keyboard.hpp:319
@ Search
Keyboard Search key.
Definition Keyboard.hpp:320
@ Undo
Keyboard Undo key.
Definition Keyboard.hpp:297
@ MediaPreviousTrack
Keyboard Media Previous Track key.
Definition Keyboard.hpp:307
@ LaunchMail
Keyboard Launch Mail key.
Definition Keyboard.hpp:325
@ Paste
Keyboard Paste key.
Definition Keyboard.hpp:300
@ NumpadMultiply
Keypad * key.
Definition Keyboard.hpp:270
@ Execute
Keyboard Execute key.
Definition Keyboard.hpp:291
@ NumpadEnter
Keypad Enter/Return key.
Definition Keyboard.hpp:274
@ MediaStop
Keyboard Media Stop key.
Definition Keyboard.hpp:305
@ MediaNextTrack
Keyboard Media Next Track key.
Definition Keyboard.hpp:306
@ F16
Keyboard F16 key.
Definition Keyboard.hpp:245
@ Redo
Keyboard Redo key.
Definition Keyboard.hpp:296
@ Copy
Keyboard Copy key.
Definition Keyboard.hpp:299
@ Refresh
Keyboard Refresh key.
Definition Keyboard.hpp:318
@ Forward
Keyboard Forward key.
Definition Keyboard.hpp:317
@ Help
Keyboard Help key.
Definition Keyboard.hpp:293
@ LaunchApplication2
Keyboard Launch Application 2 key.
Definition Keyboard.hpp:324
@ F21
Keyboard F21 key.
Definition Keyboard.hpp:250
@ ScrollLock
Keyboard Scroll Lock key.
Definition Keyboard.hpp:256
@ F22
Keyboard F22 key.
Definition Keyboard.hpp:251
@ F18
Keyboard F18 key.
Definition Keyboard.hpp:247
@ F23
Keyboard F23 key.
Definition Keyboard.hpp:252
@ NumpadEqual
keypad = key
Definition Keyboard.hpp:273
@ CapsLock
Keyboard Caps Lock key.
Definition Keyboard.hpp:254
@ VolumeDown
Keyboard Volume Down key.
Definition Keyboard.hpp:303
@ VolumeMute
Keyboard Volume Mute key.
Definition Keyboard.hpp:301
@ NumpadDecimal
Keypad . and Delete key.
Definition Keyboard.hpp:275
@ NumpadPlus
Keypad + key.
Definition Keyboard.hpp:272
@ MediaPlayPause
Keyboard Media Play Pause key.
Definition Keyboard.hpp:304
@ NumpadDivide
Keypad / key.
Definition Keyboard.hpp:269
@ PrintScreen
Keyboard Print Screen key.
Definition Keyboard.hpp:255
@ HomePage
Keyboard Home Page key.
Definition Keyboard.hpp:322
@ NonUsBackslash
Keyboard Non-US \ and | key.
Definition Keyboard.hpp:289
@ F19
Keyboard F19 key.
Definition Keyboard.hpp:248
@ NumLock
Keypad Num Lock and Clear key.
Definition Keyboard.hpp:268
@ LaunchApplication1
Keyboard Launch Application 1 key.
Definition Keyboard.hpp:323
@ Favorites
Keyboard Favorites key.
Definition Keyboard.hpp:321
@ Select
Keyboard Select key.
Definition Keyboard.hpp:295
@ Application
Keyboard Application key.
Definition Keyboard.hpp:290
@ ModeChange
Keyboard Mode Change key.
Definition Keyboard.hpp:292
@ Cut
Keyboard Cut key.
Definition Keyboard.hpp:298
@ F24
Keyboard F24 key.
Definition Keyboard.hpp:253
@ VolumeUp
Keyboard Volume Up key.
Definition Keyboard.hpp:302
@ NumpadMinus
Keypad - key.
Definition Keyboard.hpp:271
@ F20
Keyboard F20 key.
Definition Keyboard.hpp:249
@ F17
Keyboard F17 key.
Definition Keyboard.hpp:246