SDL_HINT_KEYCODE_OPTIONS(3)
π SDL_HINT_KEYCODE_OPTIONS(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today we're decoding the lil' string that decides how your keycodes get to glow up before they hit your event loop π¦
β¨ NAME β¨
SDL_HINT_KEYCODE_OPTIONS β a variable (yes, just a humble string) that controls how keycodes get represented in keyboard events π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_hints.h>
#define SDL_HINT_KEYCODE_OPTIONS "SDL_KEYCODE_OPTIONS"
like, that's it. that's the whole vibe. one #define, infinite power π
β¨ DESCRIPTION β¨
So this variable is a comma separated set of options for translating keycodes in events. You feed it a string, it decides which flavor of keycode you get. no cap π
Here's the menu, one bullet each, no skips:
"none"β keycode options are cleared, and this overrides other options. like a reset button, or a "leave me alone" text. periodt."hide_numpad"β the numpad keysyms get translated into their non-numpad versions based on the current NumLock state. For example,SDLK_KP_4would becomeSDLK_4ifSDL_KMOD_NUMis set in the event modifiers, andSDLK_LEFTif it is unset. so numpad 4 is either a 4 or an arrow, depending on your NumLock mood swings π"french_numbers"β the number row on French keyboards is inverted, so pressing the1key would yield the keycodeSDLK_1, or'1', instead ofSDLK_AMPERSAND, or'&'. genuinely iconic, French keyboards said "we do it our way" π«π·β¨"latin_letters"β for keyboards using non-Latin letters, such as Russian or Thai, the letter keys generate keycodes as though it had an English QWERTY layout. e.g. pressing the key associated withSDL_SCANCODE_Aon a Russian keyboard would yield'a'instead of a Cyrillic letter. it's giving "translate me to QWERTY bestie" π
The default value for this hint is "french_numbers,latin_letters" β so yeah, out of the box you already get the French numbers and the Latin letters. slay.
Some platforms like Emscripten only provide modified keycodes and the options are not used. so on those, this whole hint is lowkey just vibing in the background, unread π
Also important, and I need you to hear this: these options do not affect the return value of SDL_GetKeyFromScancode() or SDL_GetScancodeFromKey(). They just apply to the keycode included in key events. So don't come for those two functions, they're innocent π
Oh and the good news: this hint can be set anytime. no setup window, no ceremony, just set it whenever. main character energy fr fr.
β¨ AVAILABILITY β¨
This hint is available since SDL 3.2.0. if you're on something older, sorry babe, it's not there yet π
π a lil sign-off π
That's the whole page, bestie! This came to you from the Simple Directmedia Layer crew, version SDL 3.4.18, filed under SDL_HINT_KEYCODE_OPTIONS(3). go forth and set your hint string, and remember: "none" overrides everything, so don't say I didn't warn you π«Άπ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms