SDL_GetScancodeName(3)
β¨ SDL_GetScancodeName π
okay bestie, so this one is SDL_GetScancodeName(3) from the SDL3 functions era β she's a little lookup girlie who hands you a cute human-readable name for a scancode π no cap, that's the whole job.
πΈ NAME πΈ
SDL_GetScancodeName β get a human-readable name for a scancode. literally just vibes and strings π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_keyboard.h>
const char * SDL_GetScancodeName(SDL_Scancode scancode);
π¦ DESCRIPTION π¦
β οΈ warning bestie, this is the important part β οΈ
The name you get back is by design not stable across platforms. She's not consistent, she's not loyal, she's platform-dependent. fr fr.
Likeβ¦ the name for SDL_SCANCODE_LGUI is "Left GUI" under Linux but "Left Windows" under Microsoft Windows π same key, different name, no consistency.
And some scancodes like SDL_SCANCODE_NONUSBACKSLASH don't have any name at all. Not even a placeholder. Nothing. π
There are even scancodes that share names β e.g. SDL_SCANCODE_RETURN and SDL_SCANCODE_RETURN2 are both called "Return". Two different keys, one name, and they're both just out here living their truth.
Because of all that, this function is therefore unsuitable for creating a stable cross-platform two-way mapping between strings and scancodes. Don't try it. It's giving heartbreak. π«Ά
π FUNCTION PARAMETERS π
scancodeβ the desiredSDL_Scancodeyou wanna query. that's it, that's the girl β¨
π RETURN VALUE π
Returns a pointer to the name for the scancode π
If the scancode doesn't have a name, this function returns an empty string (""). yeah, empty. not NULL. an empty string. noted bestie π
π§ THREAD SAFETY π§
This function is not thread safe. π¨
do not be calling her from multiple threads at once, she cannot handle that energy π
β AVAILABILITY β
This function is available since SDL 3.2.0. so if your SDL is older than that, she simply does not exist yet π
π₯ SEE ALSO π₯
and that's the whole page bestie, you ate it π β¨ mwah!
sign-off time: this lil masterpiece comes to you courtesy of Simple Directmedia Layer, sitting pretty at version SDL 3.4.18 π iykyk β go name some scancodes, just don't build a mapping table out of them, that's the one thing she said not to do ππ¦
π¦ 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