SDL_GetKeyName(3)
β¨ SDL_GetKeyName β¨
okay so bestie, welcome to the SDL3 FUNCTIONS corner of the man pages π this one's called SDL_GetKeyName and it's literally the girl who tells you what a key is called, in human words π
πΈ NAME πΈ
SDL_GetKeyName β get a human-readable name for a key π«Ά
π¦ SYNOPSIS π¦
#include <SDL3/SDL_keyboard.h>
const char * SDL_GetKeyName(SDL_Keycode key);
like, one header, one function, one key. that's the whole vibe β¨
π DESCRIPTION π
so you hand it a key and it hands you back the name of that key. cute, right?
now the important part: if the key doesn't have a name, this function returns an empty string (""). not NULL, not a shrug emoji, just a lil empty string π so if you get nothing back, that's not a bug, that's the answer.
and letters? they will be presented in their uppercase form, if applicable. so yes, it's giving A, not a. uppercase main character energy π
π FUNCTION PARAMETERS π
keyβ the desiredSDL_Keycodeto query. this is the key you're asking about, the one you're like "bestie who are you" to π
β RETURN VALUE β
returns a UTF-8 encoded string of the key name π
that's the whole thing. no exit codes, no errno drama, just a string. slay.
π₯ THREAD SAFETY π₯
this function is NOT thread safe. π
fr fr, do not be calling this from a bunch of threads at once thinking it's fine. it is not fine. keep it to one thread, i'm begging π
π AVAILABILITY π
this function has been available since SDL 3.2.0 β¨ so if you're on something older, no key names for you, sorry babe π
π SEE ALSO π
SDL_GetKeyFromName(3)β the reverse bestie, name goes in, key comes outSDL_GetKeyFromScancode(3)β scancode in, keycode outSDL_GetScancodeFromKey(3)β keycode in, scancode out
iykyk, these four are the little friend group π«Ά
and that's the page!! go forth and name your keys π
Simple Directmedia Layer π¦ SDL 3.4.18 π SDL_GetKeyName(3) β mwah, ily, bye bestie π
β¨
π¦ 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