SDL_KeyboardEvent Struct Reference

`#include <SDL_events.h>`

## Data Fields

SDL_EventType | type
Uint32 | reserved
Uint64 | timestamp
SDL_WindowID | windowID
SDL_KeyboardID | which
SDL_Scancode | scancode
SDL_Keycode | key
SDL_Keymod | mod
Uint16 | raw
bool | down
bool | repeat

## Detailed Description

Keyboard button event structure (event.key.*)

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().

Since
  This struct is available since SDL 3.2.0.

See also
  SDL_GetKeyFromScancode
  SDL_HINT_KEYCODE_OPTIONS

Definition at line 351 of file SDL_events.h.

## Field Documentation

## down

bool SDL_KeyboardEvent::down

true if the key is pressed

Definition at line 362 of file SDL_events.h.

## key

SDL_Keycode SDL_KeyboardEvent::key

SDL virtual key code

Definition at line 359 of file SDL_events.h.

## mod

SDL_Keymod SDL_KeyboardEvent::mod

current key modifiers

Definition at line 360 of file SDL_events.h.

## raw

Uint16 SDL_KeyboardEvent::raw

The platform dependent scancode for this event

Definition at line 361 of file SDL_events.h.

## repeat

bool SDL_KeyboardEvent::repeat

true if this is a key repeat

Definition at line 363 of file SDL_events.h.

## reserved

Uint32 SDL_KeyboardEvent::reserved

Definition at line 354 of file SDL_events.h.

## scancode

SDL_Scancode SDL_KeyboardEvent::scancode

SDL physical key code

Definition at line 358 of file SDL_events.h.

## timestamp

Uint64 SDL_KeyboardEvent::timestamp

In nanoseconds, populated using SDL_GetTicksNS()

Definition at line 355 of file SDL_events.h.

## type

SDL_EventType SDL_KeyboardEvent::type

SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP

Definition at line 353 of file SDL_events.h.

## which

SDL_KeyboardID SDL_KeyboardEvent::which

The keyboard instance id, or 0 if unknown or virtual

Definition at line 357 of file SDL_events.h.

## windowID

SDL_WindowID SDL_KeyboardEvent::windowID

The window with keyboard focus, if any

Definition at line 356 of file SDL_events.h.

The documentation for this struct was generated from the following file:

- SDL_events.h