Loading...
Searching...
No Matches
Keyboard.h File Reference

Go to the source code of this file.

Enumerations

enum  sfKeyCode {
  sfKeyUnknown = -1 , sfKeyA , sfKeyB , sfKeyC ,
  sfKeyD , sfKeyE , sfKeyF , sfKeyG ,
  sfKeyH , sfKeyI , sfKeyJ , sfKeyK ,
  sfKeyL , sfKeyM , sfKeyN , sfKeyO ,
  sfKeyP , sfKeyQ , sfKeyR , sfKeyS ,
  sfKeyT , sfKeyU , sfKeyV , sfKeyW ,
  sfKeyX , sfKeyY , sfKeyZ , sfKeyNum0 ,
  sfKeyNum1 , sfKeyNum2 , sfKeyNum3 , sfKeyNum4 ,
  sfKeyNum5 , sfKeyNum6 , sfKeyNum7 , sfKeyNum8 ,
  sfKeyNum9 , sfKeyEscape , sfKeyLControl , sfKeyLShift ,
  sfKeyLAlt , sfKeyLSystem , sfKeyRControl , sfKeyRShift ,
  sfKeyRAlt , sfKeyRSystem , sfKeyMenu , sfKeyLBracket ,
  sfKeyRBracket , sfKeySemicolon , sfKeyComma , sfKeyPeriod ,
  sfKeyApostrophe , sfKeySlash , sfKeyBackslash , sfKeyGrave ,
  sfKeyEqual , sfKeyHyphen , sfKeySpace , sfKeyEnter ,
  sfKeyBackspace , sfKeyTab , sfKeyPageUp , sfKeyPageDown ,
  sfKeyEnd , sfKeyHome , sfKeyInsert , sfKeyDelete ,
  sfKeyAdd , sfKeySubtract , sfKeyMultiply , sfKeyDivide ,
  sfKeyLeft , sfKeyRight , sfKeyUp , sfKeyDown ,
  sfKeyNumpad0 , sfKeyNumpad1 , sfKeyNumpad2 , sfKeyNumpad3 ,
  sfKeyNumpad4 , sfKeyNumpad5 , sfKeyNumpad6 , sfKeyNumpad7 ,
  sfKeyNumpad8 , sfKeyNumpad9 , sfKeyF1 , sfKeyF2 ,
  sfKeyF3 , sfKeyF4 , sfKeyF5 , sfKeyF6 ,
  sfKeyF7 , sfKeyF8 , sfKeyF9 , sfKeyF10 ,
  sfKeyF11 , sfKeyF12 , sfKeyF13 , sfKeyF14 ,
  sfKeyF15 , sfKeyPause , sfKeyCount , sfKeyTilde = sfKeyGrave ,
  sfKeyDash = sfKeyHyphen , sfKeyBack = sfKeyBackspace , sfKeyBackSlash = sfKeyBackslash , sfKeySemiColon = sfKeySemicolon ,
  sfKeyReturn = sfKeyEnter , sfKeyQuote = sfKeyApostrophe
}
 Key codes. More...
 
enum  sfScancode {
  sfScanUnknown = -1 , sfScanA = 0 , sfScanB , sfScanC ,
  sfScanD , sfScanE , sfScanF , sfScanG ,
  sfScanH , sfScanI , sfScanJ , sfScanK ,
  sfScanL , sfScanM , sfScanN , sfScanO ,
  sfScanP , sfScanQ , sfScanR , sfScanS ,
  sfScanT , sfScanU , sfScanV , sfScanW ,
  sfScanX , sfScanY , sfScanZ , sfScanNum1 ,
  sfScanNum2 , sfScanNum3 , sfScanNum4 , sfScanNum5 ,
  sfScanNum6 , sfScanNum7 , sfScanNum8 , sfScanNum9 ,
  sfScanNum0 , sfScanEnter , sfScanEscape , sfScanBackspace ,
  sfScanTab , sfScanSpace , sfScanHyphen , sfScanEqual ,
  sfScanLBracket , sfScanRBracket , sfScanBackslash , sfScanSemicolon ,
  sfScanApostrophe , sfScanGrave , sfScanComma , sfScanPeriod ,
  sfScanSlash , sfScanF1 , sfScanF2 , sfScanF3 ,
  sfScanF4 , sfScanF5 , sfScanF6 , sfScanF7 ,
  sfScanF8 , sfScanF9 , sfScanF10 , sfScanF11 ,
  sfScanF12 , sfScanF13 , sfScanF14 , sfScanF15 ,
  sfScanF16 , sfScanF17 , sfScanF18 , sfScanF19 ,
  sfScanF20 , sfScanF21 , sfScanF22 , sfScanF23 ,
  sfScanF24 , sfScanCapsLock , sfScanPrintScreen , sfScanScrollLock ,
  sfScanPause , sfScanInsert , sfScanHome , sfScanPageUp ,
  sfScanDelete , sfScanEnd , sfScanPageDown , sfScanRight ,
  sfScanLeft , sfScanDown , sfScanUp , sfScanNumLock ,
  sfScanNumpadDivide , sfScanNumpadMultiply , sfScanNumpadMinus , sfScanNumpadPlus ,
  sfScanNumpadEqual , sfScanNumpadEnter , sfScanNumpadDecimal , sfScanNumpad1 ,
  sfScanNumpad2 , sfScanNumpad3 , sfScanNumpad4 , sfScanNumpad5 ,
  sfScanNumpad6 , sfScanNumpad7 , sfScanNumpad8 , sfScanNumpad9 ,
  sfScanNumpad0 , sfScanNonUsBackslash , sfScanApplication , sfScanExecute ,
  sfScanModeChange , sfScanHelp , sfScanMenu , sfScanSelect ,
  sfScanRedo , sfScanUndo , sfScanCut , sfScanCopy ,
  sfScanPaste , sfScanVolumeMute , sfScanVolumeUp , sfScanVolumeDown ,
  sfScanMediaPlayPause , sfScanMediaStop , sfScanMediaNextTrack , sfScanMediaPreviousTrack ,
  sfScanLControl , sfScanLShift , sfScanLAlt , sfScanLSystem ,
  sfScanRControl , sfScanRShift , sfScanRAlt , sfScanRSystem ,
  sfScanBack , sfScanForward , sfScanRefresh , sfScanStop ,
  sfScanSearch , sfScanFavorites , sfScanHomePage , sfScanLaunchApplication1 ,
  sfScanLaunchApplication2 , sfScanLaunchMail , sfScanLaunchMediaSelect , sfScancodeCount
}
 Scancodes. More...
 

Functions

sfBool sfKeyboard_isKeyPressed (sfKeyCode key)
 Check if a key is pressed.
 
sfBool 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 (sfBool visible)
 Show or hide the virtual keyboard.
 

Enumeration Type Documentation

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

Enumerator
sfKeyUnknown 

Unhandled key.

sfKeyA 

The A key.

sfKeyB 

The B key.

sfKeyC 

The C key.

sfKeyD 

The D key.

sfKeyE 

The E key.

sfKeyF 

The F key.

sfKeyG 

The G key.

sfKeyH 

The H key.

sfKeyI 

The I key.

sfKeyJ 

The J key.

sfKeyK 

The K key.

sfKeyL 

The L key.

sfKeyM 

The M key.

sfKeyN 

The N key.

sfKeyO 

The O key.

sfKeyP 

The P key.

sfKeyQ 

The Q key.

sfKeyR 

The R key.

sfKeyS 

The S key.

sfKeyT 

The T key.

sfKeyU 

The U key.

sfKeyV 

The V key.

sfKeyW 

The W key.

sfKeyX 

The X key.

sfKeyY 

The Y key.

sfKeyZ 

The Z key.

sfKeyNum0 

The 0 key.

sfKeyNum1 

The 1 key.

sfKeyNum2 

The 2 key.

sfKeyNum3 

The 3 key.

sfKeyNum4 

The 4 key.

sfKeyNum5 

The 5 key.

sfKeyNum6 

The 6 key.

sfKeyNum7 

The 7 key.

sfKeyNum8 

The 8 key.

sfKeyNum9 

The 9 key.

sfKeyEscape 

The Escape key.

sfKeyLControl 

The left Control key.

sfKeyLShift 

The left Shift key.

sfKeyLAlt 

The left Alt key.

sfKeyLSystem 

The left OS specific key: window (Windows and Linux), apple (macOS), ...

sfKeyRControl 

The right Control key.

sfKeyRShift 

The right Shift key.

sfKeyRAlt 

The right Alt key.

sfKeyRSystem 

The right OS specific key: window (Windows and Linux), apple (macOS), ...

sfKeyMenu 

The Menu key.

sfKeyLBracket 

The [ key.

sfKeyRBracket 

The ] key.

sfKeySemicolon 

The ; key.

sfKeyComma 

The , key.

sfKeyPeriod 

The . key.

sfKeyApostrophe 

The ' key.

sfKeySlash 

The / key.

sfKeyBackslash 

The \ key.

sfKeyGrave 

The ` key.

sfKeyEqual 

The = key.

sfKeyHyphen 

The - key (hyphen)

sfKeySpace 

The Space key.

sfKeyEnter 

The Enter/Return key.

sfKeyBackspace 

The Backspace key.

sfKeyTab 

The Tabulation key.

sfKeyPageUp 

The Page up key.

sfKeyPageDown 

The Page down key.

sfKeyEnd 

The End key.

sfKeyHome 

The Home key.

sfKeyInsert 

The Insert key.

sfKeyDelete 

The Delete key.

sfKeyAdd 

The + key.

sfKeySubtract 

The - key (minus, usually from numpad)

sfKeyMultiply 

The * key.

sfKeyDivide 

The / key.

sfKeyLeft 

Left arrow.

sfKeyRight 

Right arrow.

sfKeyUp 

Up arrow.

sfKeyDown 

Down arrow.

sfKeyNumpad0 

The numpad 0 key.

sfKeyNumpad1 

The numpad 1 key.

sfKeyNumpad2 

The numpad 2 key.

sfKeyNumpad3 

The numpad 3 key.

sfKeyNumpad4 

The numpad 4 key.

sfKeyNumpad5 

The numpad 5 key.

sfKeyNumpad6 

The numpad 6 key.

sfKeyNumpad7 

The numpad 7 key.

sfKeyNumpad8 

The numpad 8 key.

sfKeyNumpad9 

The numpad 9 key.

sfKeyF1 

The F1 key.

sfKeyF2 

The F2 key.

sfKeyF3 

The F3 key.

sfKeyF4 

The F4 key.

sfKeyF5 

The F5 key.

sfKeyF6 

The F6 key.

sfKeyF7 

The F7 key.

sfKeyF8 

The F8 key.

sfKeyF9 

The F8 key.

sfKeyF10 

The F10 key.

sfKeyF11 

The F11 key.

sfKeyF12 

The F12 key.

sfKeyF13 

The F13 key.

sfKeyF14 

The F14 key.

sfKeyF15 

The F15 key.

sfKeyPause 

The Pause key.

sfKeyCount 

Keep last – the total number of keyboard keys.

sfKeyTilde 
Deprecated:
Use Grave instead
sfKeyDash 
Deprecated:
Use Hyphen instead
sfKeyBack 
Deprecated:
Use Backspace instead
sfKeyBackSlash 
Deprecated:
Use Backslash instead
sfKeySemiColon 
Deprecated:
Use Semicolon instead
sfKeyReturn 
Deprecated:
Use Enter instead
sfKeyQuote 
Deprecated:
Use Apostrophe instead

Definition at line 42 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.

Enumerator
sfScanUnknown 

Represents any scancode not present in this enum.

sfScanA 

Keyboard a and A key.

sfScanB 

Keyboard b and B key.

sfScanC 

Keyboard c and C key.

sfScanD 

Keyboard d and D key.

sfScanE 

Keyboard e and E key.

sfScanF 

Keyboard f and F key.

sfScanG 

Keyboard g and G key.

sfScanH 

Keyboard h and H key.

sfScanI 

Keyboard i and I key.

sfScanJ 

Keyboard j and J key.

sfScanK 

Keyboard k and K key.

sfScanL 

Keyboard l and L key.

sfScanM 

Keyboard m and M key.

sfScanN 

Keyboard n and N key.

sfScanO 

Keyboard o and O key.

sfScanP 

Keyboard p and P key.

sfScanQ 

Keyboard q and Q key.

sfScanR 

Keyboard r and R key.

sfScanS 

Keyboard s and S key.

sfScanT 

Keyboard t and T key.

sfScanU 

Keyboard u and U key.

sfScanV 

Keyboard v and V key.

sfScanW 

Keyboard w and W key.

sfScanX 

Keyboard x and X key.

sfScanY 

Keyboard y and Y key.

sfScanZ 

Keyboard z and Z key.

sfScanNum1 

Keyboard 1 and ! key.

sfScanNum2 

Keyboard 2 and @ key.

sfScanNum3 

Keyboard 3 and # key.

sfScanNum4 

Keyboard 4 and $ key.

sfScanNum5 

Keyboard 5 and % key.

sfScanNum6 

Keyboard 6 and ^ key.

sfScanNum7 

Keyboard 7 and & key.

sfScanNum8 

Keyboard 8 and * key.

sfScanNum9 

Keyboard 9 and ) key.

sfScanNum0 

Keyboard 0 and ) key.

sfScanEnter 

Keyboard Enter/Return key.

sfScanEscape 

Keyboard Escape key.

sfScanBackspace 

Keyboard Backspace key.

sfScanTab 

Keyboard Tab key.

sfScanSpace 

Keyboard Space key.

sfScanHyphen 

Keyboard - and _ key.

sfScanEqual 

Keyboard = and +.

sfScanLBracket 

Keyboard [ and { key.

sfScanRBracket 

Keyboard ] and } key.

sfScanBackslash 

Keyboard \ and | key OR various keys for Non-US keyboards.

sfScanSemicolon 

Keyboard ; and : key.

sfScanApostrophe 

Keyboard ' and " key.

sfScanGrave 

Keyboard ` and ~ key.

sfScanComma 

Keyboard , and < key.

sfScanPeriod 

Keyboard . and > key.

sfScanSlash 

Keyboard / and ? key.

sfScanF1 

Keyboard F1 key.

sfScanF2 

Keyboard F2 key.

sfScanF3 

Keyboard F3 key.

sfScanF4 

Keyboard F4 key.

sfScanF5 

Keyboard F5 key.

sfScanF6 

Keyboard F6 key.

sfScanF7 

Keyboard F7 key.

sfScanF8 

Keyboard F8 key.

sfScanF9 

Keyboard F9 key.

sfScanF10 

Keyboard F10 key.

sfScanF11 

Keyboard F11 key.

sfScanF12 

Keyboard F12 key.

sfScanF13 

Keyboard F13 key.

sfScanF14 

Keyboard F14 key.

sfScanF15 

Keyboard F15 key.

sfScanF16 

Keyboard F16 key.

sfScanF17 

Keyboard F17 key.

sfScanF18 

Keyboard F18 key.

sfScanF19 

Keyboard F19 key.

sfScanF20 

Keyboard F20 key.

sfScanF21 

Keyboard F21 key.

sfScanF22 

Keyboard F22 key.

sfScanF23 

Keyboard F23 key.

sfScanF24 

Keyboard F24 key.

sfScanCapsLock 

Keyboard Caps Lock key.

sfScanPrintScreen 

Keyboard Print Screen key.

sfScanScrollLock 

Keyboard Scroll Lock key.

sfScanPause 

Keyboard Pause key.

sfScanInsert 

Keyboard Insert key.

sfScanHome 

Keyboard Home key.

sfScanPageUp 

Keyboard Page Up key.

sfScanDelete 

Keyboard Delete Forward key.

sfScanEnd 

Keyboard End key.

sfScanPageDown 

Keyboard Page Down key.

sfScanRight 

Keyboard Right Arrow key.

sfScanLeft 

Keyboard Left Arrow key.

sfScanDown 

Keyboard Down Arrow key.

sfScanUp 

Keyboard Up Arrow key.

sfScanNumLock 

Keypad Num Lock and Clear key.

sfScanNumpadDivide 

Keypad / key.

sfScanNumpadMultiply 

Keypad * key.

sfScanNumpadMinus 

Keypad - key.

sfScanNumpadPlus 

Keypad + key.

sfScanNumpadEqual 

keypad = key

sfScanNumpadEnter 

Keypad Enter/Return key.

sfScanNumpadDecimal 

Keypad . and Delete key.

sfScanNumpad1 

Keypad 1 and End key.

sfScanNumpad2 

Keypad 2 and Down Arrow key.

sfScanNumpad3 

Keypad 3 and Page Down key.

sfScanNumpad4 

Keypad 4 and Left Arrow key.

sfScanNumpad5 

Keypad 5 key.

sfScanNumpad6 

Keypad 6 and Right Arrow key.

sfScanNumpad7 

Keypad 7 and Home key.

sfScanNumpad8 

Keypad 8 and Up Arrow key.

sfScanNumpad9 

Keypad 9 and Page Up key.

sfScanNumpad0 

Keypad 0 and Insert key.

sfScanNonUsBackslash 

Keyboard Non-US \ and | key.

sfScanApplication 

Keyboard Application key.

sfScanExecute 

Keyboard Execute key.

sfScanModeChange 

Keyboard Mode Change key.

sfScanHelp 

Keyboard Help key.

sfScanMenu 

Keyboard Menu key.

sfScanSelect 

Keyboard Select key.

sfScanRedo 

Keyboard Redo key.

sfScanUndo 

Keyboard Undo key.

sfScanCut 

Keyboard Cut key.

sfScanCopy 

Keyboard Copy key.

sfScanPaste 

Keyboard Paste key.

sfScanVolumeMute 

Keyboard Volume Mute key.

sfScanVolumeUp 

Keyboard Volume Up key.

sfScanVolumeDown 

Keyboard Volume Down key.

sfScanMediaPlayPause 

Keyboard Media Play Pause key.

sfScanMediaStop 

Keyboard Media Stop key.

sfScanMediaNextTrack 

Keyboard Media Next Track key.

sfScanMediaPreviousTrack 

Keyboard Media Previous Track key.

sfScanLControl 

Keyboard Left Control key.

sfScanLShift 

Keyboard Left Shift key.

sfScanLAlt 

Keyboard Left Alt key.

sfScanLSystem 

Keyboard Left System key.

sfScanRControl 

Keyboard Right Control key.

sfScanRShift 

Keyboard Right Shift key.

sfScanRAlt 

Keyboard Right Alt key.

sfScanRSystem 

Keyboard Right System key.

sfScanBack 

Keyboard Back key.

sfScanForward 

Keyboard Forward key.

sfScanRefresh 

Keyboard Refresh key.

sfScanStop 

Keyboard Stop key.

sfScanSearch 

Keyboard Search key.

sfScanFavorites 

Keyboard Favorites key.

sfScanHomePage 

Keyboard Home Page key.

sfScanLaunchApplication1 

Keyboard Launch Application 1 key.

sfScanLaunchApplication2 

Keyboard Launch Application 2 key.

sfScanLaunchMail 

Keyboard Launch Mail key.

sfScanLaunchMediaSelect 

Keyboard Launch Media Select key.

sfScancodeCount 

Keep last – the total number of scancodes.

Definition at line 169 of file Keyboard.h.

Function Documentation

◆ sfKeyboard_delocalize()

sfScancode sfKeyboard_delocalize ( sfKeyCode  key)

Identify the physical key corresponding to a logical one.

Parameters
keyKey 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
codeScancode to describe
Returns
The localized description of the code

◆ sfKeyboard_isKeyPressed()

sfBool sfKeyboard_isKeyPressed ( sfKeyCode  key)

Check if a key is pressed.

Parameters
keyKey to check
Returns
sfTrue if the key is pressed, sfFalse otherwise
See also
sfKeyboard_isScancodePressed

◆ sfKeyboard_isScancodePressed()

sfBool sfKeyboard_isScancodePressed ( sfScancode  code)

Check if a key is pressed.

Parameters
codeScancode to check
Returns
sfTrue if the physical key is pressed, sfFalse otherwise
See also
sfKeyboard_isKeyPressed

◆ sfKeyboard_localize()

sfKeyCode sfKeyboard_localize ( sfScancode  code)

Localize a physical key to a logical one.

Parameters
codeScancode 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 ( sfBool  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
visibleTrue to show, false to hide