SDL_KeyboardEvent(3type)
π SDL_KeyboardEvent β the keyboard event struct, bestie
okay so you're here for SDL_KeyboardEvent(3type), the keyboard button event structure (event.key.*) from the SDL3 datatypes club. pull up a chair, this one's actually adorable once you see it. β¨
β¨ SYNOPSIS β¨
#include <SDL3/SDL_events.h>
typedef struct SDL_KeyboardEvent
{
SDL_EventType type; /**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */
SDL_Scancode scancode; /**< SDL physical key code */
SDL_Keycode key; /**< SDL virtual key code */
SDL_Keymod mod; /**< current key modifiers */
Uint16 raw; /**< The platform dependent scancode for this event */
bool down; /**< true if the key is pressed */
bool repeat; /**< true if this is a key repeat */
} SDL_KeyboardEvent;
π DESCRIPTION π
okay so lowkey the whole plot twist here is key. like, the key is the base SDL_Keycode you get by pressing the scancode using the current keyboard layout, and it also applies any options you specified in SDL_HINT_KEYCODE_OPTIONS. the way it justβ¦ does all that for you. π
and if you wanna be extra (valid), you can get the SDL_Keycode that corresponds to the event's scancode and mod directly from the keyboard layout, bypassing SDL_HINT_KEYCODE_OPTIONS entirely, by calling SDL_GetKeyFromScancode(). yep. shortcut queen behavior. π
π AVAILABILITY π
this struct has been serving since SDL 3.2.0. vintage, but like, the good kind. π¦
π SEE ALSO π
not me writing a whole love letter to a C struct. anyway. go press some keys, bestie, the events are eventing. π₯
mwah, this page is brought to you by Simple Directmedia Layer π and it's riding with SDL 3.4.18. go forth and keyboard-event responsibly, ily, byeeee πβ¨π«Ά
π¦ 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