#include <CSFML/Window/Export.h>
Go to the source code of this file.
Functions | |
bool | sfKeyboard_isKeyPressed (sfKeyCode key) |
Check if a key is pressed. | |
bool | sfKeyboard_isScancodePressed (sfScancode code) |
Check if a key is pressed. | |
sfKeyCode | sfKeyboard_localize (sfScancode code) |
Localize a physical key to a logical one. | |
sfScancode | sfKeyboard_delocalize (sfKeyCode key) |
Identify the physical key corresponding to a logical one. | |
const char * | sfKeyboard_getDescription (sfScancode code) |
Provide a string representation for a given scancode. | |
void | sfKeyboard_setVirtualKeyboardVisible (bool visible) |
Show or hide the virtual keyboard. | |
Enumeration Type Documentation
◆ anonymous enum
anonymous enum |
Enumerator | |
---|---|
sfKeyCount | The total number of keyboard keys. |
Definition at line 147 of file Keyboard.h.
◆ anonymous enum
anonymous enum |
Enumerator | |
---|---|
sfScancodeCount | The total number of scancodes. |
Definition at line 317 of file Keyboard.h.
◆ sfKeyCode
enum sfKeyCode |
Key codes.
The enumerators refer to the "localized" key; i.e. depending on the layout set by the operating system, a key can be mapped to Y
or Z
.
Definition at line 41 of file Keyboard.h.
◆ sfScancode
enum sfScancode |
Scancodes.
The enumerators are bound to a physical key and do not depend on the keyboard layout used by the operating system. Usually, the AT-101 keyboard can be used as reference for the physical position of the keys.
Definition at line 160 of file Keyboard.h.
Function Documentation
◆ sfKeyboard_delocalize()
sfScancode sfKeyboard_delocalize | ( | sfKeyCode | key | ) |
Identify the physical key corresponding to a logical one.
- Parameters
-
key Key to "delocalize"
- Returns
- The scancode corresponding to the key under the current keyboard layout used by the operating system, or sfScanUnknown when the key cannot be mapped to a sfScancode.
- See also
- sfKeyboard_localize
◆ sfKeyboard_getDescription()
const char * sfKeyboard_getDescription | ( | sfScancode | code | ) |
Provide a string representation for a given scancode.
The returned string is a short, non-technical description of the key represented with the given scancode. Most effectively used in user interfaces, as the description for the key takes the users keyboard layout into consideration.
- Warning
- The result is OS-dependent: for example, sfScanLSystem is "Left Meta" on Linux, "Left Windows" on Windows and "Left Command" on macOS.
The current keyboard layout set by the operating system is used to interpret the scancode: for example, sfKeySemicolon is mapped to ";" for layout and to "é" for others.
The returned const char* owns the string and must be freed to avoid memory leaks.
- Parameters
-
code Scancode to describe
- Returns
- The localized description of the code
◆ sfKeyboard_isKeyPressed()
bool sfKeyboard_isKeyPressed | ( | sfKeyCode | key | ) |
Check if a key is pressed.
- Parameters
-
key Key to check
- Returns
- true if the key is pressed, false otherwise
- See also
- sfKeyboard_isScancodePressed
◆ sfKeyboard_isScancodePressed()
bool sfKeyboard_isScancodePressed | ( | sfScancode | code | ) |
Check if a key is pressed.
- Parameters
-
code Scancode to check
- Returns
- true if the physical key is pressed, false otherwise
- See also
- sfKeyboard_isKeyPressed
◆ sfKeyboard_localize()
sfKeyCode sfKeyboard_localize | ( | sfScancode | code | ) |
Localize a physical key to a logical one.
- Parameters
-
code Scancode to localize
- Returns
- The key corresponding to the scancode under the current keyboard layout used by the operating system, or sfKeyUnknown when the scancode cannot be mapped to a Key.
- See also
- sfKeyboard_delocalize
◆ sfKeyboard_setVirtualKeyboardVisible()
void sfKeyboard_setVirtualKeyboardVisible | ( | bool | visible | ) |
Show or hide the virtual keyboard.
- Warning
- The virtual keyboard is not supported on all systems. It will typically be implemented on mobile OSes (Android, iOS) but not on desktop OSes (Windows, Linux, ...).
If the virtual keyboard is not available, this function does nothing.
- Parameters
-
visible True to show, false to hide