TSdlScancode
The SDL keyboard scancode representation.
An SDL scancode is the physical representation of a key on the keyboard, independent of language and keyboard mapping.
Values of this type are used to represent keyboard keys, among other places in the Scancode
property of TSdlKeyboardEvent.
The values in this enumeration are based on the USB usage page standard.
Definition
Unit: Neslib.Sdl3.Input
Enumeration Values
Unknown = SDL_SCANCODE_UNKNOWN
A = SDL_SCANCODE_A
B = SDL_SCANCODE_B
C = SDL_SCANCODE_C
D = SDL_SCANCODE_D
E = SDL_SCANCODE_E
F = SDL_SCANCODE_F
G = SDL_SCANCODE_G
H = SDL_SCANCODE_H
I = SDL_SCANCODE_I
J = SDL_SCANCODE_J
K = SDL_SCANCODE_K
L = SDL_SCANCODE_L
M = SDL_SCANCODE_M
N = SDL_SCANCODE_N
O = SDL_SCANCODE_O
P = SDL_SCANCODE_P
Q = SDL_SCANCODE_Q
R = SDL_SCANCODE_R
S = SDL_SCANCODE_S
T = SDL_SCANCODE_T
U = SDL_SCANCODE_U
V = SDL_SCANCODE_V
W = SDL_SCANCODE_W
X = SDL_SCANCODE_X
Y = SDL_SCANCODE_Y
Z = SDL_SCANCODE_Z
_1 = SDL_SCANCODE_1
_2 = SDL_SCANCODE_2
_3 = SDL_SCANCODE_3
_4 = SDL_SCANCODE_4
_5 = SDL_SCANCODE_5
_6 = SDL_SCANCODE_6
_7 = SDL_SCANCODE_7
_8 = SDL_SCANCODE_8
_9 = SDL_SCANCODE_9
_0 = SDL_SCANCODE_0
Return = SDL_SCANCODE_RETURN
Escape = SDL_SCANCODE_ESCAPE
Backspace = SDL_SCANCODE_BACKSPACE
Tab = SDL_SCANCODE_TAB
Space = SDL_SCANCODE_SPACE
Minus = SDL_SCANCODE_MINUS
Equals = SDL_SCANCODE_EQUALS
LeftBracket = SDL_SCANCODE_LEFTBRACKET
RightBracket = SDL_SCANCODE_RIGHTBRACKET
Backslash = SDL_SCANCODE_BACKSLASH
Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout.
NonUSHash = SDL_SCANCODE_NONUSHASH
ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDL_SCANCODE_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards.
SemiColon = SDL_SCANCODE_SEMICOLON
Apostrophe = SDL_SCANCODE_APOSTROPHE
Grave = SDL_SCANCODE_GRAVE
Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards.
Comma = SDL_SCANCODE_COMMA
Period = SDL_SCANCODE_PERIOD
Slash = SDL_SCANCODE_SLASH
CapsLock = SDL_SCANCODE_CAPSLOCK
F1 = SDL_SCANCODE_F1
F2 = SDL_SCANCODE_F2
F3 = SDL_SCANCODE_F3
F4 = SDL_SCANCODE_F4
F5 = SDL_SCANCODE_F5
F6 = SDL_SCANCODE_F6
F7 = SDL_SCANCODE_F7
F8 = SDL_SCANCODE_F8
F9 = SDL_SCANCODE_F9
F10 = SDL_SCANCODE_F10
F11 = SDL_SCANCODE_F11
F12 = SDL_SCANCODE_F12
PrintScreen = SDL_SCANCODE_PRINTSCREEN
ScrollLock = SDL_SCANCODE_SCROLLLOCK
Pause = SDL_SCANCODE_PAUSE
Insert = SDL_SCANCODE_INSERT
Insert on PC, help on some Mac keyboards (but does send code 73, not 117)
Home = SDL_SCANCODE_HOME
PageUp = SDL_SCANCODE_PAGEUP
Delete = SDL_SCANCODE_DELETE
&End = SDL_SCANCODE_END
PageDown = SDL_SCANCODE_PAGEDOWN
Right = SDL_SCANCODE_RIGHT
Left = SDL_SCANCODE_LEFT
Down = SDL_SCANCODE_DOWN
Up = SDL_SCANCODE_UP
NumLockClear = SDL_SCANCODE_NUMLOCKCLEAR
Num lock on PC, clear on Mac keyboards
KPDivide = SDL_SCANCODE_KP_DIVIDE
KPMultiply = SDL_SCANCODE_KP_MULTIPLY
KPMinus = SDL_SCANCODE_KP_MINUS
KPPlus = SDL_SCANCODE_KP_PLUS
KPEnter = SDL_SCANCODE_KP_ENTER
KP1 = SDL_SCANCODE_KP_1
KP2 = SDL_SCANCODE_KP_2
KP3 = SDL_SCANCODE_KP_3
KP4 = SDL_SCANCODE_KP_4
KP5 = SDL_SCANCODE_KP_5
KP6 = SDL_SCANCODE_KP_6
KP7 = SDL_SCANCODE_KP_7
KP8 = SDL_SCANCODE_KP_8
KP9 = SDL_SCANCODE_KP_9
KP0 = SDL_SCANCODE_KP_0
KPPeriod = SDL_SCANCODE_KP_PERIOD
NonUSBackslash = SDL_SCANCODE_NONUSBACKSLASH
This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Y. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout.
Application = SDL_SCANCODE_APPLICATION
windows contextual menu, compose
Power = SDL_SCANCODE_POWER
The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key.
KPEquals = SDL_SCANCODE_KP_EQUALS
F13 = SDL_SCANCODE_F13
F14 = SDL_SCANCODE_F14
F15 = SDL_SCANCODE_F15
F16 = SDL_SCANCODE_F16
F17 = SDL_SCANCODE_F17
F18 = SDL_SCANCODE_F18
F19 = SDL_SCANCODE_F19
F20 = SDL_SCANCODE_F20
F21 = SDL_SCANCODE_F21
F22 = SDL_SCANCODE_F22
F23 = SDL_SCANCODE_F23
F24 = SDL_SCANCODE_F24
EXECUTE = SDL_SCANCODE_EXECUTE
Help = SDL_SCANCODE_HELP
AL Integrated Help Center
Menu = SDL_SCANCODE_MENU
Menu (show menu)
Select = SDL_SCANCODE_SELECT
Stop = SDL_SCANCODE_STOP
AC Stop
Again = SDL_SCANCODE_AGAIN
AC Redo/Repeat
Undo = SDL_SCANCODE_UNDO
AC Undo
Cut = SDL_SCANCODE_CUT
AC Cut
Copy = SDL_SCANCODE_COPY
AC Copy
Paste = SDL_SCANCODE_PASTE
AC Paste
Find = SDL_SCANCODE_FIND
AC Find
Mute = SDL_SCANCODE_MUTE
VolumeUp = SDL_SCANCODE_VOLUMEUP
VolumeDown = SDL_SCANCODE_VOLUMEDOWN
KPComma = SDL_SCANCODE_KP_COMMA
KPEqualsAS400 = SDL_SCANCODE_KP_EQUALSAS400
International1 = SDL_SCANCODE_INTERNATIONAL1
used on Asian keyboards, see footnotes in USB doc
International2 = SDL_SCANCODE_INTERNATIONAL2
International3 = SDL_SCANCODE_INTERNATIONAL3
Yen
International4 = SDL_SCANCODE_INTERNATIONAL4
International5 = SDL_SCANCODE_INTERNATIONAL5
International6 = SDL_SCANCODE_INTERNATIONAL6
International7 = SDL_SCANCODE_INTERNATIONAL7
International8 = SDL_SCANCODE_INTERNATIONAL8
International9 = SDL_SCANCODE_INTERNATIONAL9
Lang1 = SDL_SCANCODE_LANG1
Hangul/English toggle
Lang2 = SDL_SCANCODE_LANG2
Hanja conversion
Lang3 = SDL_SCANCODE_LANG3
Katakana
Lang4 = SDL_SCANCODE_LANG4
Hiragana
Lang5 = SDL_SCANCODE_LANG5
Zenkaku/Hankaku
Lang6 = SDL_SCANCODE_LANG6
reserved
Lang7 = SDL_SCANCODE_LANG7
reserved
Lang8 = SDL_SCANCODE_LANG8
reserved
Lang9 = SDL_SCANCODE_LANG9
reserved
AltErase = SDL_SCANCODE_ALTERASE
Erase-Eaze
SysReq = SDL_SCANCODE_SYSREQ
Cancel = SDL_SCANCODE_CANCEL
AC Cancel
Clear = SDL_SCANCODE_CLEAR
Prior = SDL_SCANCODE_PRIOR
Return2 = SDL_SCANCODE_RETURN2
Separator = SDL_SCANCODE_SEPARATOR
&Out = SDL_SCANCODE_OUT
Oper = SDL_SCANCODE_OPER
ClearAgain = SDL_SCANCODE_CLEARAGAIN
CRSel = SDL_SCANCODE_CRSEL
EXSel = SDL_SCANCODE_EXSEL
KP00 = SDL_SCANCODE_KP_00
KP000 = SDL_SCANCODE_KP_000
ThousandsSeparator = SDL_SCANCODE_THOUSANDSSEPARATOR
DecimalSeparator = SDL_SCANCODE_DECIMALSEPARATOR
CurrencyUnit = SDL_SCANCODE_CURRENCYUNIT
CurrencySubUnit = SDL_SCANCODE_CURRENCYSUBUNIT
KPLeftParen = SDL_SCANCODE_KP_LEFTPAREN
KPRightParen = SDL_SCANCODE_KP_RIGHTPAREN
KPLeftBrace = SDL_SCANCODE_KP_LEFTBRACE
KPRightBrace = SDL_SCANCODE_KP_RIGHTBRACE
KPTab = SDL_SCANCODE_KP_TAB
KPBackspace = SDL_SCANCODE_KP_BACKSPACE
KPA = SDL_SCANCODE_KP_A
KPB = SDL_SCANCODE_KP_B
KPC = SDL_SCANCODE_KP_C
KPD = SDL_SCANCODE_KP_D
KPE = SDL_SCANCODE_KP_E
KPF = SDL_SCANCODE_KP_F
KPXor = SDL_SCANCODE_KP_XOR
KPPower = SDL_SCANCODE_KP_POWER
KPPercent = SDL_SCANCODE_KP_PERCENT
KPLess = SDL_SCANCODE_KP_LESS
KPGreater = SDL_SCANCODE_KP_GREATER
KPAmpersand = SDL_SCANCODE_KP_AMPERSAND
KPDblAmpersand = SDL_SCANCODE_KP_DBLAMPERSAND
KPVerticalBar = SDL_SCANCODE_KP_VERTICALBAR
KPDblVerticalBar = SDL_SCANCODE_KP_DBLVERTICALBAR
KPColon = SDL_SCANCODE_KP_COLON
KPHash = SDL_SCANCODE_KP_HASH
KPSpace = SDL_SCANCODE_KP_SPACE
KPAt = SDL_SCANCODE_KP_AT
KPExclam = SDL_SCANCODE_KP_EXCLAM
KPMemStore = SDL_SCANCODE_KP_MEMSTORE
KPMemRecall = SDL_SCANCODE_KP_MEMRECALL
KPMemClear = SDL_SCANCODE_KP_MEMCLEAR
KPMemAdd = SDL_SCANCODE_KP_MEMADD
KPMemSubtract = SDL_SCANCODE_KP_MEMSUBTRACT
KPMemMultiply = SDL_SCANCODE_KP_MEMMULTIPLY
KPMemDivide = SDL_SCANCODE_KP_MEMDIVIDE
KPPlusMinus = SDL_SCANCODE_KP_PLUSMINUS
KPClear = SDL_SCANCODE_KP_CLEAR
KPClearEntry = SDL_SCANCODE_KP_CLEARENTRY
KPBinary = SDL_SCANCODE_KP_BINARY
KPOctal = SDL_SCANCODE_KP_OCTAL
KPDecimal = SDL_SCANCODE_KP_DECIMAL
KPHexadecimal = SDL_SCANCODE_KP_HEXADECIMAL
LCtrl = SDL_SCANCODE_LCTRL
LShift = SDL_SCANCODE_LSHIFT
LAlt = SDL_SCANCODE_LALT
Alt, option
LGui = SDL_SCANCODE_LGUI
Windows, command (apple), meta
RCtrl = SDL_SCANCODE_RCTRL
RShift = SDL_SCANCODE_RSHIFT
RAlt = SDL_SCANCODE_RALT
Alt gr, option
RGui = SDL_SCANCODE_RGUI
Windows, command (apple), meta
Mode = SDL_SCANCODE_MODE
I'm not sure if this is really not covered by any of the above, but since there's a special SDL_KMOD_MODE for it I'm adding it here
Sleep = SDL_SCANCODE_SLEEP
Sleep
Wake = SDL_SCANCODE_WAKE
Wake
ChannelIncrement = SDL_SCANCODE_CHANNEL_INCREMENT
Channel Increment
ChannelDecrement = SDL_SCANCODE_CHANNEL_DECREMENT
Channel Decrement
MediaPlay = SDL_SCANCODE_MEDIA_PLAY
Play
MediaPause = SDL_SCANCODE_MEDIA_PAUSE
Pause
MediaRecord = SDL_SCANCODE_MEDIA_RECORD
Record
MediaFastForward = SDL_SCANCODE_MEDIA_FAST_FORWARD
Fast Forward
MediaRewind = SDL_SCANCODE_MEDIA_REWIND
Rewind
MediaNextTrack = SDL_SCANCODE_MEDIA_NEXT_TRACK
Next Track
MediaPreviousTrack = SDL_SCANCODE_MEDIA_PREVIOUS_TRACK
Previous Track
MediaStop = SDL_SCANCODE_MEDIA_STOP
Stop
MediaEject = SDL_SCANCODE_MEDIA_EJECT
Eject
MediaPlayPause = SDL_SCANCODE_MEDIA_PLAY_PAUSE
Play / Pause
MediaSelect = SDL_SCANCODE_MEDIA_SELECT
ACNew = SDL_SCANCODE_AC_NEW
AC New
ACOpen = SDL_SCANCODE_AC_OPEN
AC Open
ACClose = SDL_SCANCODE_AC_CLOSE
AC Close
ACExit = SDL_SCANCODE_AC_EXIT
AC Exit
ACSave = SDL_SCANCODE_AC_SAVE
AC Save
ACPrint = SDL_SCANCODE_AC_PRINT
AC Print
ACProperties = SDL_SCANCODE_AC_PROPERTIES
AC Properties
ACSearch = SDL_SCANCODE_AC_SEARCH
AC Search
ACHome = SDL_SCANCODE_AC_HOME
AC Home
ACBack = SDL_SCANCODE_AC_BACK
AC Back
ACForward = SDL_SCANCODE_AC_FORWARD
AC Forward
ACStop = SDL_SCANCODE_AC_STOP
AC Stop
ACRefresh = SDL_SCANCODE_AC_REFRESH
AC Refresh
ACBookmarks = SDL_SCANCODE_AC_BOOKMARKS
AC Bookmarks
SoftLeft = SDL_SCANCODE_SOFTLEFT
Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom left of the display.
SoftRight = SDL_SCANCODE_SOFTRIGHT
Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom right of the display.
Call = SDL_SCANCODE_CALL
Used for accepting phone calls.
EndCall = SDL_SCANCODE_ENDCALL
Used for rejecting phone calls.
Properties
Name | Description |
---|---|
Name | A human-readable name for the scancode. |
Methods
Name | Description |
---|---|
FromKeycode(TSdlKeycode) | Get the scancode corresponding to the given key code according to the current keyboard layout. |
FromKeycode(TSdlKeycode, TSdlKeyMods) | Get the scancode corresponding to the given key code according to the current keyboard layout. |
FromName | Get a scancode from a human-readable name. |
ToKeycode | Converts the scancode to a TSdlKeycode. |
ToKeycode(TSdlKeymods, Boolean) | Get the key code corresponding to this scancode according to the current keyboard layout. |
Property Descriptions
Name
A human-readable name for the scancode.
Warning: The returned name is by design not stable across platforms, e.g. the name for TSdlScancode.LGui
is 'Left GUI' under Linux but 'Left Windows' under Microsoft Windows, and some scancodes like TSdlScancode.NonUSBackslash
don't have any name at all. There are even scancodes that share names, e.g. TSdlScancode.Return
and TSdlScancode.Return2
(both called 'Return'). This property is therefore unsuitable for creating a stable cross-platform two-way mapping between strings and scancodes.
You can also set this property to a different name.
property Name: String read GetName write SetName
Type: String
Exceptions
ESdlError
: Raised on failure.
See Also
Remarks
This property is not thread safe.
Method Descriptions
FromKeycode(TSdlKeycode)
Get the scancode corresponding to the given key code according to the current keyboard layout.
class function FromKeycode(const AKey: TSdlKeycode): TSdlScancode; overload; inline; static
Parameters
AKey
: TSdlKeycode
: The desired keycode to query.
Returns
TSdlScancode
: The scancode that corresponds to the given keycode.
See Also
Remarks
This method is not thread safe.
FromKeycode(TSdlKeycode, TSdlKeyMods)
Get the scancode corresponding to the given key code according to the current keyboard layout.
Note that there may be multiple scancode+modifier states that can generate this keycode, this will just return the first one found.
class function FromKeycode(const AKey: TSdlKeycode; const AModState: TSdlKeyMods): TSdlScancode; overload; inline; static
Parameters
AKey
: TSdlKeycode
: The desired keycode to query.
AModState
: TSdlKeyMods
: The modifier state that would be used when the scancode generates this key.
Returns
TSdlScancode
: The scancode that corresponds to the given keycode.
See Also
Remarks
This method is not thread safe.
FromName(String)
Get a scancode from a human-readable name.
class function FromName(const AName: String): TSdlScancode; inline; static
Parameters
AName
: String
: The human-readable scancode name.
Returns
TSdlScancode
: The scancode, or TSdlScancode.Unknown
if the name wasn't recognized.
See Also
Remarks
This method is not thread safe.
ToKeycode
Converts the scancode to a TSdlKeycode.
function ToKeycode: TSdlKeycode; overload; inline
Returns
TSdlKeycode
: The keycode for this scancode.
ToKeycode(TSdlKeymods, Boolean)
Get the key code corresponding to this scancode according to the current keyboard layout.
If you want to get the keycode as it would be delivered in key events, including options specified in TSdlHints.KeycodeOptions, then you should pass AKeyEvent
as True. Otherwise this function simply translates the scancode based on the given modifier state.
function ToKeycode(const AModState: TSdlKeymods; const AKeyEvent: Boolean): TSdlKeycode; overload; inline
Parameters
AModState
: TSdlKeymods
: The modifier state to use when translating the scancode to a keycode.
AKeyEvent
: Boolean
: True if the keycode will be used in key events.
Returns
TSdlKeycode
: The keycode that corresponds to the given scancode.
See Also
Remarks
This method is not thread safe.