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 desired SDL_Scancode you 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