SDL_Scancode(3type)

πŸ’– NAME πŸ’–

SDL_Scancode β€” the SDL keyboard scancode representation. that's the whole vibe. this page lives in the SDL3 DATATYPES corner of the manual, so if you're here you're probably deep in keyboard handling and honestly? respect. πŸŽ€


✨ SYNOPSIS ✨

okay bestie, first the include, then the enum. heads up: everything from SDL_SCANCODE_A onward is lifted straight out of usage page 0x07, aka the USB keyboard page β€” SDL says so right there in the \name doc comment, and there's a /* @{ */ group marker kicking the block off. no cap. πŸ‘‘

#include <SDL3/SDL_scancode.h>

typedef enum SDL_Scancode
{
    SDL_SCANCODE_UNKNOWN = 0,

    /**
     *  \name Usage page 0x07
     *
     *  These values are from usage page 0x07 (USB keyboard page).
     */
    /* @{ */

    SDL_SCANCODE_A = 4,
    SDL_SCANCODE_B = 5,
    SDL_SCANCODE_C = 6,
    SDL_SCANCODE_D = 7,
    SDL_SCANCODE_E = 8,
    SDL_SCANCODE_F = 9,
    SDL_SCANCODE_G = 10,
    SDL_SCANCODE_H = 11,
    SDL_SCANCODE_I = 12,
    SDL_SCANCODE_J = 13,
    SDL_SCANCODE_K = 14,
    SDL_SCANCODE_L = 15,
    SDL_SCANCODE_M = 16,
    SDL_SCANCODE_N = 17,
    SDL_SCANCODE_O = 18,
    SDL_SCANCODE_P = 19,
    SDL_SCANCODE_Q = 20,
    SDL_SCANCODE_R = 21,
    SDL_SCANCODE_S = 22,
    SDL_SCANCODE_T = 23,
    SDL_SCANCODE_U = 24,
    SDL_SCANCODE_V = 25,
    SDL_SCANCODE_W = 26,
    SDL_SCANCODE_X = 27,
    SDL_SCANCODE_Y = 28,
    SDL_SCANCODE_Z = 29,

    SDL_SCANCODE_1 = 30,
    SDL_SCANCODE_2 = 31,
    SDL_SCANCODE_3 = 32,
    SDL_SCANCODE_4 = 33,
    SDL_SCANCODE_5 = 34,
    SDL_SCANCODE_6 = 35,
    SDL_SCANCODE_7 = 36,
    SDL_SCANCODE_8 = 37,
    SDL_SCANCODE_9 = 38,
    SDL_SCANCODE_0 = 39,

    SDL_SCANCODE_RETURN = 40,
    SDL_SCANCODE_ESCAPE = 41,
    SDL_SCANCODE_BACKSPACE = 42,
    SDL_SCANCODE_TAB = 43,
    SDL_SCANCODE_SPACE = 44,

    SDL_SCANCODE_MINUS = 45,
    SDL_SCANCODE_EQUALS = 46,
    SDL_SCANCODE_LEFTBRACKET = 47,
    SDL_SCANCODE_RIGHTBRACKET = 48,
    SDL_SCANCODE_BACKSLASH = 49, /**< 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.
                                  */
    SDL_SCANCODE_NONUSHASH = 50, /**< 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.
                                  */
    SDL_SCANCODE_SEMICOLON = 51,
    SDL_SCANCODE_APOSTROPHE = 52,
    SDL_SCANCODE_GRAVE = 53, /**< 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.
                              */
    SDL_SCANCODE_COMMA = 54,
    SDL_SCANCODE_PERIOD = 55,
    SDL_SCANCODE_SLASH = 56,

    SDL_SCANCODE_CAPSLOCK = 57,

    SDL_SCANCODE_F1 = 58,
    SDL_SCANCODE_F2 = 59,
    SDL_SCANCODE_F3 = 60,
    SDL_SCANCODE_F4 = 61,
    SDL_SCANCODE_F5 = 62,
    SDL_SCANCODE_F6 = 63,
    SDL_SCANCODE_F7 = 64,
    SDL_SCANCODE_F8 = 65,
    SDL_SCANCODE_F9 = 66,
    SDL_SCANCODE_F10 = 67,
    SDL_SCANCODE_F11 = 68,
    SDL_SCANCODE_F12 = 69,

    SDL_SCANCODE_PRINTSCREEN = 70,
    SDL_SCANCODE_SCROLLLOCK = 71,
    SDL_SCANCODE_PAUSE = 72,
    SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
                                   does send code 73, not 117) */
    SDL_SCANCODE_HOME = 74,
    SDL_SCANCODE_PAGEUP = 75,
    SDL_SCANCODE_DELETE = 76,
    SDL_SCANCODE_END = 77,
    SDL_SCANCODE_PAGEDOWN = 78,
    SDL_SCANCODE_RIGHT = 79,
    SDL_SCANCODE_LEFT = 80,
    SDL_SCANCODE_DOWN = 81,
    SDL_SCANCODE_UP = 82,

    SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards
                                     */
    SDL_SCANCODE_KP_DIVIDE = 84,
    SDL_SCANCODE_KP_MULTIPLY = 85,
    SDL_SCANCODE_KP_MINUS = 86,
    SDL_SCANCODE_KP_PLUS = 87,
    SDL_SCANCODE_KP_ENTER = 88,
    SDL_SCANCODE_KP_1 = 89,
    SDL_SCANCODE_KP_2 = 90,
    SDL_SCANCODE_KP_3 = 91,
    SDL_SCANCODE_KP_4 = 92,
    SDL_SCANCODE_KP_5 = 93,
    SDL_SCANCODE_KP_6 = 94,
    SDL_SCANCODE_KP_7 = 95,
    SDL_SCANCODE_KP_8 = 96,
    SDL_SCANCODE_KP_9 = 97,
    SDL_SCANCODE_KP_0 = 98,
    SDL_SCANCODE_KP_PERIOD = 99,

    SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
                                        *   keyboards have over ANSI ones,
                                        *   located between left shift and Z.
                                        *   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. */
    SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */
    SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag,
                               *   not a physical key - but some Mac keyboards
                               *   do have a power key. */
    SDL_SCANCODE_KP_EQUALS = 103,
    SDL_SCANCODE_F13 = 104,
    SDL_SCANCODE_F14 = 105,
    SDL_SCANCODE_F15 = 106,
    SDL_SCANCODE_F16 = 107,
    SDL_SCANCODE_F17 = 108,
    SDL_SCANCODE_F18 = 109,
    SDL_SCANCODE_F19 = 110,
    SDL_SCANCODE_F20 = 111,
    SDL_SCANCODE_F21 = 112,
    SDL_SCANCODE_F22 = 113,
    SDL_SCANCODE_F23 = 114,
    SDL_SCANCODE_F24 = 115,
    SDL_SCANCODE_EXECUTE = 116,
    SDL_SCANCODE_HELP = 117,    /**< AL Integrated Help Center */
    SDL_SCANCODE_MENU = 118,    /**< Menu (show menu) */
    SDL_SCANCODE_SELECT = 119,
    SDL_SCANCODE_STOP = 120,    /**< AC Stop */
    SDL_SCANCODE_AGAIN = 121,   /**< AC Redo/Repeat */
    SDL_SCANCODE_UNDO = 122,    /**< AC Undo */
    SDL_SCANCODE_CUT = 123,     /**< AC Cut */
    SDL_SCANCODE_COPY = 124,    /**< AC Copy */
    SDL_SCANCODE_PASTE = 125,   /**< AC Paste */
    SDL_SCANCODE_FIND = 126,    /**< AC Find */
    SDL_SCANCODE_MUTE = 127,
    SDL_SCANCODE_VOLUMEUP = 128,
    SDL_SCANCODE_VOLUMEDOWN = 129,
/* not sure whether there's a reason to enable these */
/*     SDL_SCANCODE_LOCKINGCAPSLOCK = 130,  */
/*     SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
/*     SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
    SDL_SCANCODE_KP_COMMA = 133,
    SDL_SCANCODE_KP_EQUALSAS400 = 134,

    SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
                                            footnotes in USB doc */
    SDL_SCANCODE_INTERNATIONAL2 = 136,
    SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */
    SDL_SCANCODE_INTERNATIONAL4 = 138,
    SDL_SCANCODE_INTERNATIONAL5 = 139,
    SDL_SCANCODE_INTERNATIONAL6 = 140,
    SDL_SCANCODE_INTERNATIONAL7 = 141,
    SDL_SCANCODE_INTERNATIONAL8 = 142,
    SDL_SCANCODE_INTERNATIONAL9 = 143,
    SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */
    SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */
    SDL_SCANCODE_LANG3 = 146, /**< Katakana */
    SDL_SCANCODE_LANG4 = 147, /**< Hiragana */
    SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */
    SDL_SCANCODE_LANG6 = 149, /**< reserved */
    SDL_SCANCODE_LANG7 = 150, /**< reserved */
    SDL_SCANCODE_LANG8 = 151, /**< reserved */
    SDL_SCANCODE_LANG9 = 152, /**< reserved */

    SDL_SCANCODE_ALTERASE = 153,    /**< Erase-Eaze */
    SDL_SCANCODE_SYSREQ = 154,
    SDL_SCANCODE_CANCEL = 155,      /**< AC Cancel */
    SDL_SCANCODE_CLEAR = 156,
    SDL_SCANCODE_PRIOR = 157,
    SDL_SCANCODE_RETURN2 = 158,
    SDL_SCANCODE_SEPARATOR = 159,
    SDL_SCANCODE_OUT = 160,
    SDL_SCANCODE_OPER = 161,
    SDL_SCANCODE_CLEARAGAIN = 162,
    SDL_SCANCODE_CRSEL = 163,
    SDL_SCANCODE_EXSEL = 164,
    SDL_SCANCODE_FRONT = 165,   /**< Front (Sun keyboards) */

🫢 the annotated keys, bestie 🫢

okay so most of these are just… the key. SDL_SCANCODE_A = 4 is the A key. periodt. nothing to explain. but SDL left little love notes on a handful of them, and those notes are highkey iconic because international keyboards are a whole beautiful mess. here is every single one, no skipping, I promise πŸ’…

  • SDL_SCANCODE_BACKSLASH = 49 β€” this key is giving identity crisis and I'm obsessed. it's located at the lower left of the return key on ISO keyboards, and at the right end of the QWERTY row on ANSI keyboards. what it actually produces depends entirely on your layout: 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. 😭
  • SDL_SCANCODE_NONUSHASH = 50 β€” plot twist: ISO USB keyboards actually use this code instead of 49 for that same key. but every OS the author has seen treats the two codes identically. so if you're 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 one. and if you're a user: do not rely on this code, because SDL will never generate it with most (all?) keyboards. πŸ’€
  • SDL_SCANCODE_GRAVE = 53 β€” top left corner, on both ANSI and ISO keyboards, and it's a whole chameleon. it 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. 🌈
  • SDL_SCANCODE_INSERT = 73 β€” it's insert on PC, and help on some Mac keyboards β€” but (and this is the important bit) it does send code 73, not 117. noted. πŸ“
  • SDL_SCANCODE_NUMLOCKCLEAR = 83 β€” num lock on PC, clear on Mac keyboards. one key, two jobs, main character energy honestly.
  • SDL_SCANCODE_NONUSBACKSLASH = 100 β€” this is the extra key ISO keyboards have that ANSI ones don't, sitting right between left shift and Z. it 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. ✨
  • SDL_SCANCODE_APPLICATION = 101 β€” windows contextual menu, compose.
  • SDL_SCANCODE_POWER = 102 β€” okay the USB document claims this is a status flag and not a physical key… but some Mac keyboards do have a power key. make of that what you will. πŸ™ˆ
  • SDL_SCANCODE_HELP = 117 β€” AL Integrated Help Center.
  • SDL_SCANCODE_MENU = 118 β€” Menu (show menu).
  • SDL_SCANCODE_STOP = 120 β€” AC Stop.
  • SDL_SCANCODE_AGAIN = 121 β€” AC Redo/Repeat.
  • SDL_SCANCODE_UNDO = 122 β€” AC Undo.
  • SDL_SCANCODE_CUT = 123 β€” AC Cut.
  • SDL_SCANCODE_COPY = 124 β€” AC Copy.
  • SDL_SCANCODE_PASTE = 125 β€” AC Paste.
  • SDL_SCANCODE_FIND = 126 β€” AC Find.
  • SDL_SCANCODE_INTERNATIONAL1 = 135 β€” used on Asian keyboards, and it says to see the footnotes in the USB doc. πŸ¦‹
  • SDL_SCANCODE_INTERNATIONAL3 = 137 β€” Yen.
  • SDL_SCANCODE_LANG1 = 144 β€” Hangul/English toggle.
  • SDL_SCANCODE_LANG2 = 145 β€” Hanja conversion.
  • SDL_SCANCODE_LANG3 = 146 β€” Katakana.
  • SDL_SCANCODE_LANG4 = 147 β€” Hiragana.
  • SDL_SCANCODE_LANG5 = 148 β€” Zenkaku/Hankaku.
  • SDL_SCANCODE_LANG6 = 149, SDL_SCANCODE_LANG7 = 150, SDL_SCANCODE_LANG8 = 151, SDL_SCANCODE_LANG9 = 152 β€” all four are just marked reserved. no thoughts, head empty. 🌸
  • SDL_SCANCODE_ALTERASE = 153 β€” Erase-Eaze.
  • SDL_SCANCODE_CANCEL = 155 β€” AC Cancel.
  • SDL_SCANCODE_FRONT = 165 β€” Front (Sun keyboards).
also real quick: there's a little commented-out trio in there β€” SDL_SCANCODE_LOCKINGCAPSLOCK = 130, SDL_SCANCODE_LOCKINGNUMLOCK = 131, SDL_SCANCODE_LOCKINGSCROLLLOCK = 132 β€” with the note "not sure whether there's a reason to enable these". so they're not live values, they're just vibing in comments. 🫢

and the enum literally does not stop at 165, bestie β€” there's a whole rest of the list coming in part 2, plus all the actual DESCRIPTION goodness πŸ‘‘

...and the enum just keeps going, bestie, because of course it does πŸ’… picking up exactly where we left off, no cuts, no skips:

           SDL_SCANCODE_KP_00 = 176,
           SDL_SCANCODE_KP_000 = 177,
           SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
           SDL_SCANCODE_DECIMALSEPARATOR = 179,
           SDL_SCANCODE_CURRENCYUNIT = 180,
           SDL_SCANCODE_CURRENCYSUBUNIT = 181,
           SDL_SCANCODE_KP_LEFTPAREN = 182,
           SDL_SCANCODE_KP_RIGHTPAREN = 183,
           SDL_SCANCODE_KP_LEFTBRACE = 184,
           SDL_SCANCODE_KP_RIGHTBRACE = 185,
           SDL_SCANCODE_KP_TAB = 186,
           SDL_SCANCODE_KP_BACKSPACE = 187,
           SDL_SCANCODE_KP_A = 188,
           SDL_SCANCODE_KP_B = 189,
           SDL_SCANCODE_KP_C = 190,
           SDL_SCANCODE_KP_D = 191,
           SDL_SCANCODE_KP_E = 192,
           SDL_SCANCODE_KP_F = 193,
           SDL_SCANCODE_KP_XOR = 194,
           SDL_SCANCODE_KP_POWER = 195,
           SDL_SCANCODE_KP_PERCENT = 196,
           SDL_SCANCODE_KP_LESS = 197,
           SDL_SCANCODE_KP_GREATER = 198,
           SDL_SCANCODE_KP_AMPERSAND = 199,
           SDL_SCANCODE_KP_DBLAMPERSAND = 200,
           SDL_SCANCODE_KP_VERTICALBAR = 201,
           SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
           SDL_SCANCODE_KP_COLON = 203,
           SDL_SCANCODE_KP_HASH = 204,
           SDL_SCANCODE_KP_SPACE = 205,
           SDL_SCANCODE_KP_AT = 206,
           SDL_SCANCODE_KP_EXCLAM = 207,
           SDL_SCANCODE_KP_MEMSTORE = 208,
           SDL_SCANCODE_KP_MEMRECALL = 209,
           SDL_SCANCODE_KP_MEMCLEAR = 210,
           SDL_SCANCODE_KP_MEMADD = 211,
           SDL_SCANCODE_KP_MEMSUBTRACT = 212,
           SDL_SCANCODE_KP_MEMMULTIPLY = 213,
           SDL_SCANCODE_KP_MEMDIVIDE = 214,
           SDL_SCANCODE_KP_PLUSMINUS = 215,
           SDL_SCANCODE_KP_CLEAR = 216,
           SDL_SCANCODE_KP_CLEARENTRY = 217,
           SDL_SCANCODE_KP_BINARY = 218,
           SDL_SCANCODE_KP_OCTAL = 219,
           SDL_SCANCODE_KP_DECIMAL = 220,
           SDL_SCANCODE_KP_HEXADECIMAL = 221,

           SDL_SCANCODE_LCTRL = 224,
           SDL_SCANCODE_LSHIFT = 225,
           SDL_SCANCODE_LALT = 226, /**< alt, option */
           SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */
           SDL_SCANCODE_RCTRL = 228,
           SDL_SCANCODE_RSHIFT = 229,
           SDL_SCANCODE_RALT = 230, /**< alt gr, option */
           SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */

           SDL_SCANCODE_MODE = 257,    /**< 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
                                        */

           /* @} *//* Usage page 0x07 */

           /**
            *  \name Usage page 0x0C
            *
            *  These values are mapped from usage page 0x0C (USB consumer page).
            *
            *  There are way more keys in the spec than we can represent in the
            *  current scancode range, so pick the ones that commonly come up in
            *  real world usage.
            */
           /* @{ */

           SDL_SCANCODE_SLEEP = 258,                   /**< Sleep */
           SDL_SCANCODE_WAKE = 259,                    /**< Wake */

           SDL_SCANCODE_CHANNEL_INCREMENT = 260,       /**< Channel Increment */
           SDL_SCANCODE_CHANNEL_DECREMENT = 261,       /**< Channel Decrement */

           SDL_SCANCODE_MEDIA_PLAY = 262,          /**< Play */
           SDL_SCANCODE_MEDIA_PAUSE = 263,         /**< Pause */
           SDL_SCANCODE_MEDIA_RECORD = 264,        /**< Record */
           SDL_SCANCODE_MEDIA_FAST_FORWARD = 265,  /**< Fast Forward */
           SDL_SCANCODE_MEDIA_REWIND = 266,        /**< Rewind */
           SDL_SCANCODE_MEDIA_NEXT_TRACK = 267,    /**< Next Track */
           SDL_SCANCODE_MEDIA_PREVIOUS_TRACK = 268, /**< Previous Track */
           SDL_SCANCODE_MEDIA_STOP = 269,          /**< Stop */
           SDL_SCANCODE_MEDIA_EJECT = 270,         /**< Eject */
           SDL_SCANCODE_MEDIA_PLAY_PAUSE = 271,    /**< Play / Pause */
           SDL_SCANCODE_MEDIA_SELECT = 272,        /* Media Select */

           SDL_SCANCODE_AC_NEW = 273,              /**< AC New */
           SDL_SCANCODE_AC_OPEN = 274,             /**< AC Open */
           SDL_SCANCODE_AC_CLOSE = 275,            /**< AC Close */
           SDL_SCANCODE_AC_EXIT = 276,             /**< AC Exit */
           SDL_SCANCODE_AC_SAVE = 277,             /**< AC Save */
           SDL_SCANCODE_AC_PRINT = 278,            /**< AC Print */
           SDL_SCANCODE_AC_PROPERTIES = 279,       /**< AC Properties */

           SDL_SCANCODE_AC_SEARCH = 280,           /**< AC Search */
           SDL_SCANCODE_AC_HOME = 281,             /**< AC Home */
           SDL_SCANCODE_AC_BACK = 282,             /**< AC Back */
           SDL_SCANCODE_AC_FORWARD = 283,          /**< AC Forward */
           SDL_SCANCODE_AC_STOP = 284,             /**< AC Stop */
           SDL_SCANCODE_AC_REFRESH = 285,          /**< AC Refresh */
           SDL_SCANCODE_AC_BOOKMARKS = 286,        /**< AC Bookmarks */

           /* @} *//* Usage page 0x0C */

           /**
            *  \name Mobile keys
            *
            *  These are values that are often used on mobile phones.
            */
           /* @{ */

           SDL_SCANCODE_SOFTLEFT = 287, /**< 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. */
           SDL_SCANCODE_SOFTRIGHT = 288, /**< 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. */
           SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */
           SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */

           /* @} *//* Mobile keys */

           /* Add any other keys here. */

           SDL_SCANCODE_RESERVED = 400,    /**< 400-500 reserved for dynamic keycodes */

           SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */

       } SDL_Scancode;

okay so let's just take a sec to appreciate the range on display here 😭 you got your keypad digits, your keypad math symbols, your keypad memory keys (M+ M- MΓ— MΓ·, iconic), and then a whole little block of left/right modifiers with their little whisper-comments β€” alt, option, windows, command (apple), meta, alt gr, option, and that again for the right-hand ones 🫢

and then SDL_SCANCODE_MODE = 257 shows up with the most honest comment in the whole file: the author literally isn't sure if it's really not covered by any of the above, but since there's a special SDL_KMOD_MODE for it, it got added here. self-aware king behavior πŸ’…

then a whole new batch from usage page 0x0C β€” the USB consumer page. the comment says there are way more keys in the spec than we can represent in the current scancode range, so they just picked the ones that commonly come up in real world usage. so: sleep, wake, channel increment, channel decrement, and the entire media transport bar of your dreams β€” play, pause, record, fast forward, rewind, next track, previous track, stop, eject, play/pause, and media select 🎡

then the AC crew (that's application control, bestie, not air conditioning πŸ₯²) β€” new, open, close, exit, save, print, properties, search, home, back, forward, stop, refresh, bookmarks. every single one of them, all accounted for.

then mobile keys, for the phone girlies πŸ“± β€” SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT, usually situated below the display on phones and used as multi-function feature keys for selecting a software defined function shown on the bottom left / bottom right of the display respectively, plus SDL_SCANCODE_CALL for accepting phone calls and SDL_SCANCODE_ENDCALL for rejecting them (the shade of it all πŸ’€).

then /* Add any other keys here. */ β€” a little invitation, a little blank canvas πŸŽ€

and finally the bookends: SDL_SCANCODE_RESERVED = 400 with 400-500 reserved for dynamic keycodes, and SDL_SCANCODE_COUNT = 512 which is not a key, it just marks the number of scancodes for array bounds. know your limits, periodt. and then the whole thing closes out with } SDL_Scancode; 🌈


✨ DESCRIPTION ✨

okay so what even is an SDL scancode? bestie, it's the physical representation of a key on the keyboard β€” independent of language and keyboard mapping. like, it's not about what the key says, it's about where the key is on the board. the vibes, not the label πŸ’…

values of this type are used to represent keyboard keys, and among other places you'll find them in the scancode field of the SDL_KeyboardEvent structure. so if you're reading keyboard events, that's the field you're vibing with πŸ¦‹

and where do all these values come from? the values in this enumeration are based on the USB usage page standard:

https://usb.org/sites/default/files/hut1_5.pdf

(that's a URL, not a file on your machine, so don't go looking for it in your home directory πŸ’–)


✨ AVAILABILITY ✨

this enum has been available since SDL 3.2.0 πŸŽ€ so if you're on something older, it's giving not yet, bestie.


and that's the whole page, no notes, 100% of the flags and zero of them skipped πŸ’œ this was the SDL_Scancode(3type) page from Simple Directmedia Layer, version SDL 3.4.18 β€” go forth and map your keys, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from