Keyboard button event structure (event.key.*)
Defined in <SDL3/SDL_events.h>
typedef struct SDL_KeyboardEvent
{/**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */
SDL_EventType type;
Uint32 reserved;/**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint64 timestamp; /**< The window with keyboard focus, if any */
SDL_WindowID windowID; /**< The keyboard instance id, or 0 if unknown or virtual */
SDL_KeyboardID which; /**< SDL physical key code */
SDL_Scancode scancode; /**< SDL virtual key code */
SDL_Keycode key; /**< current key modifiers */
SDL_Keymod mod; /**< The platform dependent scancode for this event */
Uint16 raw; bool down; /**< true if the key is pressed */
bool repeat; /**< true if this is a key repeat */
} SDL_KeyboardEvent;
The key
is the base SDL_Keycode generated by pressing the scancode
using the current keyboard layout, applying any options specified in SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the event scancode and modifiers directly from the keyboard layout, bypassing SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode().
This struct is available since SDL 3.1.3.