SDL_KeyboardEvent(3)

✨ SDL_KeyboardEvent ✨

okay bestie, so this is the SDL_KeyboardEvent page from the SDL API Reference, section 3 of the manual, and it's literally the whole lore of what happens when you smash a key πŸ’… buckle up


πŸŽ€ NAME πŸŽ€

SDL_KeyboardEvent β€” the keyboard event structure. that's it, that's the name, iconic behavior fr


🧚 STRUCTURE DEFINITION 🧚

here's the fit she's wearing, no cap:

typedef struct{
  Uint8 type;
  Uint8 state;
  SDL_keysym keysym;
} SDL_KeyboardEvent;

copy it exactly like that bestie, don't be out here editing structs at 2am πŸ™ˆ


πŸ¦‹ STRUCTURE DATA πŸ¦‹

the three members, one by one, they're giving main character energy:

  • type β€” it's either SDL_KEYDOWN or SDL_KEYUP. that's the whole vibe check.
  • state β€” it's either SDL_PRESSED or SDL_RELEASED.
  • keysym β€” this one's holding all the key press information. she's the one with the receipts πŸ’–

🌸 DESCRIPTION 🌸

so SDL_KeyboardEvent is a member of the SDL_Event union, and she shows up whenever an event of type SDL_KEYDOWN or SDL_KEYUP gets reported. that's her whole job and she does it flawlessly ✨

here's the tea tho: type and state actually report the same information β€” they just use different values to do it! the way that is so unnecessary and yet so real 😭

a keyboard event happens when a key is released (type=SDK_KEYUP or state=SDL_RELEASED) and also when a key is pressed (type=SDL_KEYDOWN or state=SDL_PRESSED). and the actual info about which key got pressed or released lives inside the keysym structure. she's carrying the whole plot 🫢

Note: Repeating SDL_KEYDOWN events will occur if key repeat is enabled (see SDL_EnableKeyRepeat). so if you're getting spammed, that's not a glitch bestie, that's a feature πŸ”₯

🌈 SEE ALSO 🌈

go read these next, they're all in the same friend group:

  • SDL_Event
  • SDL_keysym
  • SDL_EnableKeyRepeat
  • SDL_EnableUNICODE

okay that's the whole page, you ate it, periodt πŸ‘‘

this was brought to you by SDL, dated Tue 11 Sep 2001, 22:59, and yes she's old enough to be your mom but she's still slaying ⭐ πŸŽ€ πŸ’œ

πŸ“¦ where this page comes from