1
0

SDL_scancode.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryScancode
  20. *
  21. * Defines keyboard scancodes.
  22. *
  23. * Please refer to the Best Keyboard Practices document for details on what
  24. * this information means and how best to use it.
  25. *
  26. * https://wiki.libsdl.org/SDL3/BestKeyboardPractices
  27. */
  28. #ifndef SDL_scancode_h_
  29. #define SDL_scancode_h_
  30. #include <SDL3/SDL_stdinc.h>
  31. /**
  32. * The SDL keyboard scancode representation.
  33. *
  34. * An SDL scancode is the physical representation of a key on the keyboard,
  35. * independent of language and keyboard mapping.
  36. *
  37. * Values of this type are used to represent keyboard keys, among other places
  38. * in the `scancode` field of the SDL_KeyboardEvent structure.
  39. *
  40. * The values in this enumeration are based on the USB usage page standard:
  41. * https://usb.org/sites/default/files/hut1_5.pdf
  42. *
  43. * \since This enum is available since SDL 3.2.0.
  44. */
  45. typedef enum SDL_Scancode
  46. {
  47. SDL_SCANCODE_UNKNOWN = 0,
  48. /**
  49. * \name Usage page 0x07
  50. *
  51. * These values are from usage page 0x07 (USB keyboard page).
  52. */
  53. /* @{ */
  54. SDL_SCANCODE_A = 4,
  55. SDL_SCANCODE_B = 5,
  56. SDL_SCANCODE_C = 6,
  57. SDL_SCANCODE_D = 7,
  58. SDL_SCANCODE_E = 8,
  59. SDL_SCANCODE_F = 9,
  60. SDL_SCANCODE_G = 10,
  61. SDL_SCANCODE_H = 11,
  62. SDL_SCANCODE_I = 12,
  63. SDL_SCANCODE_J = 13,
  64. SDL_SCANCODE_K = 14,
  65. SDL_SCANCODE_L = 15,
  66. SDL_SCANCODE_M = 16,
  67. SDL_SCANCODE_N = 17,
  68. SDL_SCANCODE_O = 18,
  69. SDL_SCANCODE_P = 19,
  70. SDL_SCANCODE_Q = 20,
  71. SDL_SCANCODE_R = 21,
  72. SDL_SCANCODE_S = 22,
  73. SDL_SCANCODE_T = 23,
  74. SDL_SCANCODE_U = 24,
  75. SDL_SCANCODE_V = 25,
  76. SDL_SCANCODE_W = 26,
  77. SDL_SCANCODE_X = 27,
  78. SDL_SCANCODE_Y = 28,
  79. SDL_SCANCODE_Z = 29,
  80. SDL_SCANCODE_1 = 30,
  81. SDL_SCANCODE_2 = 31,
  82. SDL_SCANCODE_3 = 32,
  83. SDL_SCANCODE_4 = 33,
  84. SDL_SCANCODE_5 = 34,
  85. SDL_SCANCODE_6 = 35,
  86. SDL_SCANCODE_7 = 36,
  87. SDL_SCANCODE_8 = 37,
  88. SDL_SCANCODE_9 = 38,
  89. SDL_SCANCODE_0 = 39,
  90. SDL_SCANCODE_RETURN = 40,
  91. SDL_SCANCODE_ESCAPE = 41,
  92. SDL_SCANCODE_BACKSPACE = 42,
  93. SDL_SCANCODE_TAB = 43,
  94. SDL_SCANCODE_SPACE = 44,
  95. SDL_SCANCODE_MINUS = 45,
  96. SDL_SCANCODE_EQUALS = 46,
  97. SDL_SCANCODE_LEFTBRACKET = 47,
  98. SDL_SCANCODE_RIGHTBRACKET = 48,
  99. SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return
  100. * key on ISO keyboards and at the right end
  101. * of the QWERTY row on ANSI keyboards.
  102. * Produces REVERSE SOLIDUS (backslash) and
  103. * VERTICAL LINE in a US layout, REVERSE
  104. * SOLIDUS and VERTICAL LINE in a UK Mac
  105. * layout, NUMBER SIGN and TILDE in a UK
  106. * Windows layout, DOLLAR SIGN and POUND SIGN
  107. * in a Swiss German layout, NUMBER SIGN and
  108. * APOSTROPHE in a German layout, GRAVE
  109. * ACCENT and POUND SIGN in a French Mac
  110. * layout, and ASTERISK and MICRO SIGN in a
  111. * French Windows layout.
  112. */
  113. SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code
  114. * instead of 49 for the same key, but all
  115. * OSes I've seen treat the two codes
  116. * identically. So, as an implementor, unless
  117. * your keyboard generates both of those
  118. * codes and your OS treats them differently,
  119. * you should generate SDL_SCANCODE_BACKSLASH
  120. * instead of this code. As a user, you
  121. * should not rely on this code because SDL
  122. * will never generate it with most (all?)
  123. * keyboards.
  124. */
  125. SDL_SCANCODE_SEMICOLON = 51,
  126. SDL_SCANCODE_APOSTROPHE = 52,
  127. SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI
  128. * and ISO keyboards). Produces GRAVE ACCENT and
  129. * TILDE in a US Windows layout and in US and UK
  130. * Mac layouts on ANSI keyboards, GRAVE ACCENT
  131. * and NOT SIGN in a UK Windows layout, SECTION
  132. * SIGN and PLUS-MINUS SIGN in US and UK Mac
  133. * layouts on ISO keyboards, SECTION SIGN and
  134. * DEGREE SIGN in a Swiss German layout (Mac:
  135. * only on ISO keyboards), CIRCUMFLEX ACCENT and
  136. * DEGREE SIGN in a German layout (Mac: only on
  137. * ISO keyboards), SUPERSCRIPT TWO and TILDE in a
  138. * French Windows layout, COMMERCIAL AT and
  139. * NUMBER SIGN in a French Mac layout on ISO
  140. * keyboards, and LESS-THAN SIGN and GREATER-THAN
  141. * SIGN in a Swiss German, German, or French Mac
  142. * layout on ANSI keyboards.
  143. */
  144. SDL_SCANCODE_COMMA = 54,
  145. SDL_SCANCODE_PERIOD = 55,
  146. SDL_SCANCODE_SLASH = 56,
  147. SDL_SCANCODE_CAPSLOCK = 57,
  148. SDL_SCANCODE_F1 = 58,
  149. SDL_SCANCODE_F2 = 59,
  150. SDL_SCANCODE_F3 = 60,
  151. SDL_SCANCODE_F4 = 61,
  152. SDL_SCANCODE_F5 = 62,
  153. SDL_SCANCODE_F6 = 63,
  154. SDL_SCANCODE_F7 = 64,
  155. SDL_SCANCODE_F8 = 65,
  156. SDL_SCANCODE_F9 = 66,
  157. SDL_SCANCODE_F10 = 67,
  158. SDL_SCANCODE_F11 = 68,
  159. SDL_SCANCODE_F12 = 69,
  160. SDL_SCANCODE_PRINTSCREEN = 70,
  161. SDL_SCANCODE_SCROLLLOCK = 71,
  162. SDL_SCANCODE_PAUSE = 72,
  163. SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
  164. does send code 73, not 117) */
  165. SDL_SCANCODE_HOME = 74,
  166. SDL_SCANCODE_PAGEUP = 75,
  167. SDL_SCANCODE_DELETE = 76,
  168. SDL_SCANCODE_END = 77,
  169. SDL_SCANCODE_PAGEDOWN = 78,
  170. SDL_SCANCODE_RIGHT = 79,
  171. SDL_SCANCODE_LEFT = 80,
  172. SDL_SCANCODE_DOWN = 81,
  173. SDL_SCANCODE_UP = 82,
  174. SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards
  175. */
  176. SDL_SCANCODE_KP_DIVIDE = 84,
  177. SDL_SCANCODE_KP_MULTIPLY = 85,
  178. SDL_SCANCODE_KP_MINUS = 86,
  179. SDL_SCANCODE_KP_PLUS = 87,
  180. SDL_SCANCODE_KP_ENTER = 88,
  181. SDL_SCANCODE_KP_1 = 89,
  182. SDL_SCANCODE_KP_2 = 90,
  183. SDL_SCANCODE_KP_3 = 91,
  184. SDL_SCANCODE_KP_4 = 92,
  185. SDL_SCANCODE_KP_5 = 93,
  186. SDL_SCANCODE_KP_6 = 94,
  187. SDL_SCANCODE_KP_7 = 95,
  188. SDL_SCANCODE_KP_8 = 96,
  189. SDL_SCANCODE_KP_9 = 97,
  190. SDL_SCANCODE_KP_0 = 98,
  191. SDL_SCANCODE_KP_PERIOD = 99,
  192. SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
  193. * keyboards have over ANSI ones,
  194. * located between left shift and Y.
  195. * Produces GRAVE ACCENT and TILDE in a
  196. * US or UK Mac layout, REVERSE SOLIDUS
  197. * (backslash) and VERTICAL LINE in a
  198. * US or UK Windows layout, and
  199. * LESS-THAN SIGN and GREATER-THAN SIGN
  200. * in a Swiss German, German, or French
  201. * layout. */
  202. SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */
  203. SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag,
  204. * not a physical key - but some Mac keyboards
  205. * do have a power key. */
  206. SDL_SCANCODE_KP_EQUALS = 103,
  207. SDL_SCANCODE_F13 = 104,
  208. SDL_SCANCODE_F14 = 105,
  209. SDL_SCANCODE_F15 = 106,
  210. SDL_SCANCODE_F16 = 107,
  211. SDL_SCANCODE_F17 = 108,
  212. SDL_SCANCODE_F18 = 109,
  213. SDL_SCANCODE_F19 = 110,
  214. SDL_SCANCODE_F20 = 111,
  215. SDL_SCANCODE_F21 = 112,
  216. SDL_SCANCODE_F22 = 113,
  217. SDL_SCANCODE_F23 = 114,
  218. SDL_SCANCODE_F24 = 115,
  219. SDL_SCANCODE_EXECUTE = 116,
  220. SDL_SCANCODE_HELP = 117, /**< AL Integrated Help Center */
  221. SDL_SCANCODE_MENU = 118, /**< Menu (show menu) */
  222. SDL_SCANCODE_SELECT = 119,
  223. SDL_SCANCODE_STOP = 120, /**< AC Stop */
  224. SDL_SCANCODE_AGAIN = 121, /**< AC Redo/Repeat */
  225. SDL_SCANCODE_UNDO = 122, /**< AC Undo */
  226. SDL_SCANCODE_CUT = 123, /**< AC Cut */
  227. SDL_SCANCODE_COPY = 124, /**< AC Copy */
  228. SDL_SCANCODE_PASTE = 125, /**< AC Paste */
  229. SDL_SCANCODE_FIND = 126, /**< AC Find */
  230. SDL_SCANCODE_MUTE = 127,
  231. SDL_SCANCODE_VOLUMEUP = 128,
  232. SDL_SCANCODE_VOLUMEDOWN = 129,
  233. /* not sure whether there's a reason to enable these */
  234. /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
  235. /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
  236. /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
  237. SDL_SCANCODE_KP_COMMA = 133,
  238. SDL_SCANCODE_KP_EQUALSAS400 = 134,
  239. SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
  240. footnotes in USB doc */
  241. SDL_SCANCODE_INTERNATIONAL2 = 136,
  242. SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */
  243. SDL_SCANCODE_INTERNATIONAL4 = 138,
  244. SDL_SCANCODE_INTERNATIONAL5 = 139,
  245. SDL_SCANCODE_INTERNATIONAL6 = 140,
  246. SDL_SCANCODE_INTERNATIONAL7 = 141,
  247. SDL_SCANCODE_INTERNATIONAL8 = 142,
  248. SDL_SCANCODE_INTERNATIONAL9 = 143,
  249. SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */
  250. SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */
  251. SDL_SCANCODE_LANG3 = 146, /**< Katakana */
  252. SDL_SCANCODE_LANG4 = 147, /**< Hiragana */
  253. SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */
  254. SDL_SCANCODE_LANG6 = 149, /**< reserved */
  255. SDL_SCANCODE_LANG7 = 150, /**< reserved */
  256. SDL_SCANCODE_LANG8 = 151, /**< reserved */
  257. SDL_SCANCODE_LANG9 = 152, /**< reserved */
  258. SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
  259. SDL_SCANCODE_SYSREQ = 154,
  260. SDL_SCANCODE_CANCEL = 155, /**< AC Cancel */
  261. SDL_SCANCODE_CLEAR = 156,
  262. SDL_SCANCODE_PRIOR = 157,
  263. SDL_SCANCODE_RETURN2 = 158,
  264. SDL_SCANCODE_SEPARATOR = 159,
  265. SDL_SCANCODE_OUT = 160,
  266. SDL_SCANCODE_OPER = 161,
  267. SDL_SCANCODE_CLEARAGAIN = 162,
  268. SDL_SCANCODE_CRSEL = 163,
  269. SDL_SCANCODE_EXSEL = 164,
  270. SDL_SCANCODE_KP_00 = 176,
  271. SDL_SCANCODE_KP_000 = 177,
  272. SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
  273. SDL_SCANCODE_DECIMALSEPARATOR = 179,
  274. SDL_SCANCODE_CURRENCYUNIT = 180,
  275. SDL_SCANCODE_CURRENCYSUBUNIT = 181,
  276. SDL_SCANCODE_KP_LEFTPAREN = 182,
  277. SDL_SCANCODE_KP_RIGHTPAREN = 183,
  278. SDL_SCANCODE_KP_LEFTBRACE = 184,
  279. SDL_SCANCODE_KP_RIGHTBRACE = 185,
  280. SDL_SCANCODE_KP_TAB = 186,
  281. SDL_SCANCODE_KP_BACKSPACE = 187,
  282. SDL_SCANCODE_KP_A = 188,
  283. SDL_SCANCODE_KP_B = 189,
  284. SDL_SCANCODE_KP_C = 190,
  285. SDL_SCANCODE_KP_D = 191,
  286. SDL_SCANCODE_KP_E = 192,
  287. SDL_SCANCODE_KP_F = 193,
  288. SDL_SCANCODE_KP_XOR = 194,
  289. SDL_SCANCODE_KP_POWER = 195,
  290. SDL_SCANCODE_KP_PERCENT = 196,
  291. SDL_SCANCODE_KP_LESS = 197,
  292. SDL_SCANCODE_KP_GREATER = 198,
  293. SDL_SCANCODE_KP_AMPERSAND = 199,
  294. SDL_SCANCODE_KP_DBLAMPERSAND = 200,
  295. SDL_SCANCODE_KP_VERTICALBAR = 201,
  296. SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
  297. SDL_SCANCODE_KP_COLON = 203,
  298. SDL_SCANCODE_KP_HASH = 204,
  299. SDL_SCANCODE_KP_SPACE = 205,
  300. SDL_SCANCODE_KP_AT = 206,
  301. SDL_SCANCODE_KP_EXCLAM = 207,
  302. SDL_SCANCODE_KP_MEMSTORE = 208,
  303. SDL_SCANCODE_KP_MEMRECALL = 209,
  304. SDL_SCANCODE_KP_MEMCLEAR = 210,
  305. SDL_SCANCODE_KP_MEMADD = 211,
  306. SDL_SCANCODE_KP_MEMSUBTRACT = 212,
  307. SDL_SCANCODE_KP_MEMMULTIPLY = 213,
  308. SDL_SCANCODE_KP_MEMDIVIDE = 214,
  309. SDL_SCANCODE_KP_PLUSMINUS = 215,
  310. SDL_SCANCODE_KP_CLEAR = 216,
  311. SDL_SCANCODE_KP_CLEARENTRY = 217,
  312. SDL_SCANCODE_KP_BINARY = 218,
  313. SDL_SCANCODE_KP_OCTAL = 219,
  314. SDL_SCANCODE_KP_DECIMAL = 220,
  315. SDL_SCANCODE_KP_HEXADECIMAL = 221,
  316. SDL_SCANCODE_LCTRL = 224,
  317. SDL_SCANCODE_LSHIFT = 225,
  318. SDL_SCANCODE_LALT = 226, /**< alt, option */
  319. SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */
  320. SDL_SCANCODE_RCTRL = 228,
  321. SDL_SCANCODE_RSHIFT = 229,
  322. SDL_SCANCODE_RALT = 230, /**< alt gr, option */
  323. SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */
  324. SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered
  325. * by any of the above, but since there's a
  326. * special SDL_KMOD_MODE for it I'm adding it here
  327. */
  328. /* @} *//* Usage page 0x07 */
  329. /**
  330. * \name Usage page 0x0C
  331. *
  332. * These values are mapped from usage page 0x0C (USB consumer page).
  333. *
  334. * There are way more keys in the spec than we can represent in the
  335. * current scancode range, so pick the ones that commonly come up in
  336. * real world usage.
  337. */
  338. /* @{ */
  339. SDL_SCANCODE_SLEEP = 258, /**< Sleep */
  340. SDL_SCANCODE_WAKE = 259, /**< Wake */
  341. SDL_SCANCODE_CHANNEL_INCREMENT = 260, /**< Channel Increment */
  342. SDL_SCANCODE_CHANNEL_DECREMENT = 261, /**< Channel Decrement */
  343. SDL_SCANCODE_MEDIA_PLAY = 262, /**< Play */
  344. SDL_SCANCODE_MEDIA_PAUSE = 263, /**< Pause */
  345. SDL_SCANCODE_MEDIA_RECORD = 264, /**< Record */
  346. SDL_SCANCODE_MEDIA_FAST_FORWARD = 265, /**< Fast Forward */
  347. SDL_SCANCODE_MEDIA_REWIND = 266, /**< Rewind */
  348. SDL_SCANCODE_MEDIA_NEXT_TRACK = 267, /**< Next Track */
  349. SDL_SCANCODE_MEDIA_PREVIOUS_TRACK = 268, /**< Previous Track */
  350. SDL_SCANCODE_MEDIA_STOP = 269, /**< Stop */
  351. SDL_SCANCODE_MEDIA_EJECT = 270, /**< Eject */
  352. SDL_SCANCODE_MEDIA_PLAY_PAUSE = 271, /**< Play / Pause */
  353. SDL_SCANCODE_MEDIA_SELECT = 272, /* Media Select */
  354. SDL_SCANCODE_AC_NEW = 273, /**< AC New */
  355. SDL_SCANCODE_AC_OPEN = 274, /**< AC Open */
  356. SDL_SCANCODE_AC_CLOSE = 275, /**< AC Close */
  357. SDL_SCANCODE_AC_EXIT = 276, /**< AC Exit */
  358. SDL_SCANCODE_AC_SAVE = 277, /**< AC Save */
  359. SDL_SCANCODE_AC_PRINT = 278, /**< AC Print */
  360. SDL_SCANCODE_AC_PROPERTIES = 279, /**< AC Properties */
  361. SDL_SCANCODE_AC_SEARCH = 280, /**< AC Search */
  362. SDL_SCANCODE_AC_HOME = 281, /**< AC Home */
  363. SDL_SCANCODE_AC_BACK = 282, /**< AC Back */
  364. SDL_SCANCODE_AC_FORWARD = 283, /**< AC Forward */
  365. SDL_SCANCODE_AC_STOP = 284, /**< AC Stop */
  366. SDL_SCANCODE_AC_REFRESH = 285, /**< AC Refresh */
  367. SDL_SCANCODE_AC_BOOKMARKS = 286, /**< AC Bookmarks */
  368. /* @} *//* Usage page 0x0C */
  369. /**
  370. * \name Mobile keys
  371. *
  372. * These are values that are often used on mobile phones.
  373. */
  374. /* @{ */
  375. SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and
  376. used as a multi-function feature key for selecting
  377. a software defined function shown on the bottom left
  378. of the display. */
  379. SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
  380. used as a multi-function feature key for selecting
  381. a software defined function shown on the bottom right
  382. of the display. */
  383. SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */
  384. SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */
  385. /* @} *//* Mobile keys */
  386. /* Add any other keys here. */
  387. SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */
  388. SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */
  389. } SDL_Scancode;
  390. #endif /* SDL_scancode_h_ */