SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

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
30#include <SFML/Window/Export.hpp>
31
32
33 namespace sf
34{
35 class String;
36
41 namespace Keyboard
42{
51 enum class Key
52{
53 Unknown = -1,
54 A = 0,
55 B,
56 C,
57 D,
58 E,
59 F,
60 G,
61 H,
62 I,
63 J,
64 K,
65 L,
66 M,
67 N,
68 O,
69 P,
70 Q,
71 R,
72 S,
73 T,
74 U,
75 V,
76 W,
77 X,
78 Y,
79 Z,
80 Num0,
81 Num1,
82 Num2,
83 Num3,
84 Num4,
85 Num5,
86 Num6,
87 Num7,
88 Num8,
89 Num9,
90 Escape,
91 LControl,
92 LShift,
93 LAlt,
94 LSystem,
95 RControl,
96 RShift,
97 RAlt,
98 RSystem,
99 Menu,
100 LBracket,
101 RBracket,
102 Semicolon,
103 Comma,
104 Period,
105 Apostrophe,
106 Slash,
107 Backslash,
108 Grave,
109 Equal,
110 Hyphen,
111 Space,
112 Enter,
113 Backspace,
114 Tab,
115 PageUp,
116 PageDown,
117 End,
118 Home,
119 Insert,
120 Delete,
121 Add,
122 Subtract,
123 Multiply,
124 Divide,
125 Left,
126 Right,
127 Up,
128 Down,
129 Numpad0,
130 Numpad1,
131 Numpad2,
132 Numpad3,
133 Numpad4,
134 Numpad5,
135 Numpad6,
136 Numpad7,
137 Numpad8,
138 Numpad9,
139 F1,
140 F2,
141 F3,
142 F4,
143 F5,
144 F6,
145 F7,
146 F8,
147 F9,
148 F10,
149 F11,
150 F12,
151 F13,
152 F14,
153 F15,
154 Pause,
155};
156
161// NOLINTNEXTLINE(readability-identifier-naming)
162 static constexpr unsigned int KeyCount{static_cast<unsigned int>(Key::Pause) + 1};
163
172 enum class Scan
173{
174 Unknown = -1,
175 A = 0,
176 B,
177 C,
178 D,
179 E,
180 F,
181 G,
182 H,
183 I,
184 J,
185 K,
186 L,
187 M,
188 N,
189 O,
190 P,
191 Q,
192 R,
193 S,
194 T,
195 U,
196 V,
197 W,
198 X,
199 Y,
200 Z,
201 Num1,
202 Num2,
203 Num3,
204 Num4,
205 Num5,
206 Num6,
207 Num7,
208 Num8,
209 Num9,
210 Num0,
211 Enter,
212 Escape,
213 Backspace,
214 Tab,
215 Space,
216 Hyphen,
217 Equal,
218 LBracket,
219 RBracket,
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:}]
223 Backslash,
224 Semicolon,
225 Apostrophe,
226 Grave,
227 Comma,
228 Period,
229 Slash,
230 F1,
231 F2,
232 F3,
233 F4,
234 F5,
235 F6,
236 F7,
237 F8,
238 F9,
239 F10,
240 F11,
241 F12,
242 F13,
243 F14,
244 F15,
245 F16,
246 F17,
247 F18,
248 F19,
249 F20,
250 F21,
251 F22,
252 F23,
253 F24,
254 CapsLock,
255 PrintScreen,
256 ScrollLock,
257 Pause,
258 Insert,
259 Home,
260 PageUp,
261 Delete,
262 End,
263 PageDown,
264 Right,
265 Left,
266 Down,
267 Up,
268 NumLock,
269 NumpadDivide,
270 NumpadMultiply,
271 NumpadMinus,
272 NumpadPlus,
273 NumpadEqual,
274 NumpadEnter,
275 NumpadDecimal,
276 Numpad1,
277 Numpad2,
278 Numpad3,
279 Numpad4,
280 Numpad5,
281 Numpad6,
282 Numpad7,
283 Numpad8,
284 Numpad9,
285 Numpad0,
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: \|.
289 NonUsBackslash,
290 Application,
291 Execute,
292 ModeChange,
293 Help,
294 Menu,
295 Select,
296 Redo,
297 Undo,
298 Cut,
299 Copy,
300 Paste,
301 VolumeMute,
302 VolumeUp,
303 VolumeDown,
304 MediaPlayPause,
305 MediaStop,
306 MediaNextTrack,
307 MediaPreviousTrack,
308 LControl,
309 LShift,
310 LAlt,
311 LSystem,
312 RControl,
313 RShift,
314 RAlt,
315 RSystem,
316 Back,
317 Forward,
318 Refresh,
319 Stop,
320 Search,
321 Favorites,
322 HomePage,
323 LaunchApplication1,
324 LaunchApplication2,
325 LaunchMail,
326 LaunchMediaSelect,
327};
328
329 using Scancode = Scan;
330
335// NOLINTNEXTLINE(readability-identifier-naming)
336 static 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
377[[nodiscard]] SFML_WINDOW_API Key localize(Scancode code);
378
392[[nodiscard]] SFML_WINDOW_API Scancode delocalize(Key key);
393
415[[nodiscard]] SFML_WINDOW_API String getDescription(Scancode code);
416
430 SFML_WINDOW_API void setVirtualKeyboardVisible(bool visible);
431} // namespace Keyboard
432
433} // namespace sf
434
435
Export.hpp
SFML_WINDOW_API
#define SFML_WINDOW_API
Definition Window/Export.hpp:42
sf::String
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:89
sf::Keyboard::localize
Key localize(Scancode code)
Localize a physical key to a logical one.
sf::Keyboard::KeyCount
static constexpr unsigned int KeyCount
The total number of keyboard keys, ignoring Key::Unknown
Definition Keyboard.hpp:162
sf::Keyboard::ScancodeCount
static constexpr unsigned int ScancodeCount
The total number of scancodes, ignoring Scan::Unknown
Definition Keyboard.hpp:336
sf::Keyboard::delocalize
Scancode delocalize(Key key)
Identify the physical key corresponding to a logical one.
sf::Keyboard::getDescription
String getDescription(Scancode code)
Provide a string representation for a given scancode.
sf::Keyboard::setVirtualKeyboardVisible
void setVirtualKeyboardVisible(bool visible)
Show or hide the virtual keyboard.
sf::Keyboard::Key
Key
Key codes.
Definition Keyboard.hpp:52
sf::Keyboard::Key::Escape
@ Escape
The Escape key.
sf::Keyboard::Key::X
@ X
The X key.
sf::Keyboard::Key::Num6
@ Num6
The 6 key.
sf::Keyboard::Key::RAlt
@ RAlt
The right Alt key.
sf::Keyboard::Key::Down
@ Down
Down arrow.
sf::Keyboard::Key::Divide
@ Divide
The / key.
sf::Keyboard::Key::C
@ C
The C key.
sf::Keyboard::Key::Pause
@ Pause
The Pause key.
sf::Keyboard::Key::Numpad9
@ Numpad9
The numpad 9 key.
sf::Keyboard::Key::LBracket
@ LBracket
The [ key.
sf::Keyboard::Key::Period
@ Period
The . key.
sf::Keyboard::Key::Numpad0
@ Numpad0
The numpad 0 key.
sf::Keyboard::Key::Subtract
@ Subtract
The - key (minus, usually from numpad)
sf::Keyboard::Key::F6
@ F6
The F6 key.
sf::Keyboard::Key::Z
@ Z
The Z key.
sf::Keyboard::Key::F14
@ F14
The F14 key.
sf::Keyboard::Key::Up
@ Up
Up arrow.
sf::Keyboard::Key::RSystem
@ RSystem
The right OS specific key: window (Windows and Linux), apple (macOS), ...
sf::Keyboard::Key::Slash
@ Slash
The / key.
sf::Keyboard::Key::F5
@ F5
The F5 key.
sf::Keyboard::Key::E
@ E
The E key.
sf::Keyboard::Key::Numpad7
@ Numpad7
The numpad 7 key.
sf::Keyboard::Key::P
@ P
The P key.
sf::Keyboard::Key::F7
@ F7
The F7 key.
sf::Keyboard::Key::F8
@ F8
The F8 key.
sf::Keyboard::Key::Num7
@ Num7
The 7 key.
sf::Keyboard::Key::F3
@ F3
The F3 key.
sf::Keyboard::Key::U
@ U
The U key.
sf::Keyboard::Key::Numpad6
@ Numpad6
The numpad 6 key.
sf::Keyboard::Key::Numpad4
@ Numpad4
The numpad 4 key.
sf::Keyboard::Key::V
@ V
The V key.
sf::Keyboard::Key::Y
@ Y
The Y key.
sf::Keyboard::Key::Comma
@ Comma
The , key.
sf::Keyboard::Key::Tab
@ Tab
The Tabulation key.
sf::Keyboard::Key::S
@ S
The S key.
sf::Keyboard::Key::Numpad3
@ Numpad3
The numpad 3 key.
sf::Keyboard::Key::W
@ W
The W key.
sf::Keyboard::Key::Numpad5
@ Numpad5
The numpad 5 key.
sf::Keyboard::Key::F11
@ F11
The F11 key.
sf::Keyboard::Key::LShift
@ LShift
The left Shift key.
sf::Keyboard::Key::M
@ M
The M key.
sf::Keyboard::Key::Hyphen
@ Hyphen
The - key (hyphen)
sf::Keyboard::Key::Num2
@ Num2
The 2 key.
sf::Keyboard::Key::Num5
@ Num5
The 5 key.
sf::Keyboard::Key::A
@ A
The A key.
sf::Keyboard::Key::F
@ F
The F key.
sf::Keyboard::Key::Num0
@ Num0
The 0 key.
sf::Keyboard::Key::End
@ End
The End key.
sf::Keyboard::Key::Unknown
@ Unknown
Unhandled key.
sf::Keyboard::Key::F9
@ F9
The F9 key.
sf::Keyboard::Key::Num8
@ Num8
The 8 key.
sf::Keyboard::Key::Numpad8
@ Numpad8
The numpad 8 key.
sf::Keyboard::Key::Home
@ Home
The Home key.
sf::Keyboard::Key::N
@ N
The N key.
sf::Keyboard::Key::RShift
@ RShift
The right Shift key.
sf::Keyboard::Key::Right
@ Right
Right arrow.
sf::Keyboard::Key::Left
@ Left
Left arrow.
sf::Keyboard::Key::F13
@ F13
The F13 key.
sf::Keyboard::Key::Semicolon
@ Semicolon
The ; key.
sf::Keyboard::Key::PageUp
@ PageUp
The Page up key.
sf::Keyboard::Key::B
@ B
The B key.
sf::Keyboard::Key::LControl
@ LControl
The left Control key.
sf::Keyboard::Key::Num3
@ Num3
The 3 key.
sf::Keyboard::Key::Insert
@ Insert
The Insert key.
sf::Keyboard::Key::K
@ K
The K key.
sf::Keyboard::Key::LAlt
@ LAlt
The left Alt key.
sf::Keyboard::Key::RControl
@ RControl
The right Control key.
sf::Keyboard::Key::F10
@ F10
The F10 key.
sf::Keyboard::Key::Menu
@ Menu
The Menu key.
sf::Keyboard::Key::Apostrophe
@ Apostrophe
The ' key.
sf::Keyboard::Key::T
@ T
The T key.
sf::Keyboard::Key::Num1
@ Num1
The 1 key.
sf::Keyboard::Key::H
@ H
The H key.
sf::Keyboard::Key::RBracket
@ RBracket
The ] key.
sf::Keyboard::Key::Numpad1
@ Numpad1
The numpad 1 key.
sf::Keyboard::Key::Backspace
@ Backspace
The Backspace key.
sf::Keyboard::Key::L
@ L
The L key.
sf::Keyboard::Key::Space
@ Space
The Space key.
sf::Keyboard::Key::Num9
@ Num9
The 9 key.
sf::Keyboard::Key::I
@ I
The I key.
sf::Keyboard::Key::G
@ G
The G key.
sf::Keyboard::Key::Num4
@ Num4
The 4 key.
sf::Keyboard::Key::F1
@ F1
The F1 key.
sf::Keyboard::Key::R
@ R
The R key.
sf::Keyboard::Key::Multiply
@ Multiply
The * key.
sf::Keyboard::Key::F15
@ F15
The F15 key.
sf::Keyboard::Key::F4
@ F4
The F4 key.
sf::Keyboard::Key::F12
@ F12
The F12 key.
sf::Keyboard::Key::Add
@ Add
The + key.
sf::Keyboard::Key::Grave
@ Grave
The ` key.
sf::Keyboard::Key::PageDown
@ PageDown
The Page down key.
sf::Keyboard::Key::Q
@ Q
The Q key.
sf::Keyboard::Key::Enter
@ Enter
The Enter/Return keys.
sf::Keyboard::Key::O
@ O
The O key.
sf::Keyboard::Key::Delete
@ Delete
The Delete key.
sf::Keyboard::Key::Equal
@ Equal
The = key.
sf::Keyboard::Key::D
@ D
The D key.
sf::Keyboard::Key::Backslash
@ Backslash
The \ key.
sf::Keyboard::Key::Numpad2
@ Numpad2
The numpad 2 key.
sf::Keyboard::Key::LSystem
@ LSystem
The left OS specific key: window (Windows and Linux), apple (macOS), ...
sf::Keyboard::Key::F2
@ F2
The F2 key.
sf::Keyboard::Key::J
@ J
The J key.
sf::Keyboard::isKeyPressed
bool isKeyPressed(Key key)
Check if a key is pressed.
sf::Keyboard::Scan
Scan
Scancodes.
Definition Keyboard.hpp:173
sf::Keyboard::Scan::LaunchMediaSelect
@ LaunchMediaSelect
Keyboard Launch Media Select key.
sf::Keyboard::Scan::Back
@ Back
Keyboard Back key.
sf::Keyboard::Scan::Stop
@ Stop
Keyboard Stop key.
sf::Keyboard::Scan::Search
@ Search
Keyboard Search key.
sf::Keyboard::Scan::Undo
@ Undo
Keyboard Undo key.
sf::Keyboard::Scan::MediaPreviousTrack
@ MediaPreviousTrack
Keyboard Media Previous Track key.
sf::Keyboard::Scan::LaunchMail
@ LaunchMail
Keyboard Launch Mail key.
sf::Keyboard::Scan::Paste
@ Paste
Keyboard Paste key.
sf::Keyboard::Scan::NumpadMultiply
@ NumpadMultiply
Keypad * key.
sf::Keyboard::Scan::Execute
@ Execute
Keyboard Execute key.
sf::Keyboard::Scan::NumpadEnter
@ NumpadEnter
Keypad Enter/Return key.
sf::Keyboard::Scan::MediaStop
@ MediaStop
Keyboard Media Stop key.
sf::Keyboard::Scan::MediaNextTrack
@ MediaNextTrack
Keyboard Media Next Track key.
sf::Keyboard::Scan::F16
@ F16
Keyboard F16 key.
sf::Keyboard::Scan::Redo
@ Redo
Keyboard Redo key.
sf::Keyboard::Scan::Copy
@ Copy
Keyboard Copy key.
sf::Keyboard::Scan::Refresh
@ Refresh
Keyboard Refresh key.
sf::Keyboard::Scan::Forward
@ Forward
Keyboard Forward key.
sf::Keyboard::Scan::Help
@ Help
Keyboard Help key.
sf::Keyboard::Scan::LaunchApplication2
@ LaunchApplication2
Keyboard Launch Application 2 key.
sf::Keyboard::Scan::F21
@ F21
Keyboard F21 key.
sf::Keyboard::Scan::ScrollLock
@ ScrollLock
Keyboard Scroll Lock key.
sf::Keyboard::Scan::F22
@ F22
Keyboard F22 key.
sf::Keyboard::Scan::F18
@ F18
Keyboard F18 key.
sf::Keyboard::Scan::F23
@ F23
Keyboard F23 key.
sf::Keyboard::Scan::NumpadEqual
@ NumpadEqual
keypad = key
sf::Keyboard::Scan::CapsLock
@ CapsLock
Keyboard Caps Lock key.
sf::Keyboard::Scan::VolumeDown
@ VolumeDown
Keyboard Volume Down key.
sf::Keyboard::Scan::VolumeMute
@ VolumeMute
Keyboard Volume Mute key.
sf::Keyboard::Scan::NumpadDecimal
@ NumpadDecimal
Keypad . and Delete key.
sf::Keyboard::Scan::NumpadPlus
@ NumpadPlus
Keypad + key.
sf::Keyboard::Scan::MediaPlayPause
@ MediaPlayPause
Keyboard Media Play Pause key.
sf::Keyboard::Scan::NumpadDivide
@ NumpadDivide
Keypad / key.
sf::Keyboard::Scan::PrintScreen
@ PrintScreen
Keyboard Print Screen key.
sf::Keyboard::Scan::HomePage
@ HomePage
Keyboard Home Page key.
sf::Keyboard::Scan::NonUsBackslash
@ NonUsBackslash
Keyboard Non-US \ and | key.
sf::Keyboard::Scan::F19
@ F19
Keyboard F19 key.
sf::Keyboard::Scan::NumLock
@ NumLock
Keypad Num Lock and Clear key.
sf::Keyboard::Scan::LaunchApplication1
@ LaunchApplication1
Keyboard Launch Application 1 key.
sf::Keyboard::Scan::Favorites
@ Favorites
Keyboard Favorites key.
sf::Keyboard::Scan::Select
@ Select
Keyboard Select key.
sf::Keyboard::Scan::Application
@ Application
Keyboard Application key.
sf::Keyboard::Scan::ModeChange
@ ModeChange
Keyboard Mode Change key.
sf::Keyboard::Scan::Cut
@ Cut
Keyboard Cut key.
sf::Keyboard::Scan::F24
@ F24
Keyboard F24 key.
sf::Keyboard::Scan::VolumeUp
@ VolumeUp
Keyboard Volume Up key.
sf::Keyboard::Scan::NumpadMinus
@ NumpadMinus
Keypad - key.
sf::Keyboard::Scan::F20
@ F20
Keyboard F20 key.
sf::Keyboard::Scan::F17
@ F17
Keyboard F17 key.
sf
Definition AudioResource.hpp:36