###### (This is the documentation for SDL3, which is the current stable version. [SDL2](https://wiki.libsdl.org/SDL2/) was the previous version!)
# SDL_KeyboardEvent

Keyboard button event structure (event.key.*)

## Header File

Defined in [<SDL3/SDL_events.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_events.h)

## Syntax

```c
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;
```

## Remarks

The `key` is the base [SDL_Keycode](SDL_Keycode) generated by pressing the
`scancode` using the current keyboard layout, applying any options
specified in [SDL_HINT_KEYCODE_OPTIONS](SDL_HINT_KEYCODE_OPTIONS). You can
get the [SDL_Keycode](SDL_Keycode) corresponding to the event scancode and
modifiers directly from the keyboard layout, bypassing
[SDL_HINT_KEYCODE_OPTIONS](SDL_HINT_KEYCODE_OPTIONS), by calling
[SDL_GetKeyFromScancode](SDL_GetKeyFromScancode)().

## Version

This struct is available since SDL 3.1.3.

## See Also

- [SDL_GetKeyFromScancode](SDL_GetKeyFromScancode)
- [SDL_HINT_KEYCODE_OPTIONS](SDL_HINT_KEYCODE_OPTIONS)

----
[CategoryAPI](CategoryAPI), [CategoryAPIStruct](CategoryAPIStruct), [CategoryEvents](CategoryEvents)