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 desired SDL_Keycode to 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 πŸ‘‘

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