SDL_GetKeyFromScancode(3)

✨ SDL_GetKeyFromScancode ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're decoding SDL_GetKeyFromScancode β€” the lil glow-up machine that tells you which key code a scancode turns into, based on whatever keyboard layout your user is currently living in. πŸ’…


πŸŽ€ NAME πŸŽ€

SDL_GetKeyFromScancode β€” get the key code corresponding to the given scancode according to the current keyboard layout. periodt.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_keyboard.h>

SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, bool key_event);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea. β˜•

If you want the keycode exactly how it would show up in actual key events β€” like, including whatever options got specified in SDL_HINT_KEYCODE_OPTIONS β€” then you pass key_event as true. slay.

Otherwise, this function is just doing the simple thing: it translates the scancode based on the modstate you handed it. no hint energy, no extras, just vibes. ✨


πŸ’– FUNCTION PARAMETERS πŸ’–

  • scancode β€” the desired SDL_Scancode you wanna query. the thing you're curious about. πŸ‘€
  • modstate β€” the modifier state to use when translating the scancode into a keycode. shift? ctrl? whatever you're holding, tell it here.
  • key_event β€” true if the keycode is gonna be used in key events. that's it, that's the whole flag. 🫢

⭐ RETURN VALUE ⭐

Returns the SDL_Keycode that corresponds to the given SDL_Scancode. it gives you the answer, bestie. that's the whole point. πŸ”₯


πŸ’€ THREAD SAFETY πŸ’€

🚨 not thread safe. do NOT be out here calling this from multiple threads thinking it's gonna behave. it will not. one thread at a time, queen. πŸ‘‘

🌈 AVAILABILITY 🌈

this icon has been available since SDL 3.2.0. so if you're on something older… bestie, update. 😭


🧚 SEE ALSO 🧚


and that's the whole page, no cap. πŸ’œ brought to you by the fine folks at Simple Directmedia Layer, version SDL 3.4.18 β€” go forth and translate your scancodes, main character. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from