---
name: "SDL_GetKeyFromScancode"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_GetKeyFromScancode"
---

# SDL\_GetKeyFromScancode(3)

Get the key code corresponding to the given scancode according to the current keyboard layout.

## NAME

SDL\_GetKeyFromScancode - Get the key code corresponding to the given scancode according to the current keyboard layout.

## HEADER FILE

Defined in SDL3/SDL\_keyboard.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_Keycode SDL\_GetKeyFromScancode(SDL\_Scancode scancode, SDL\_Keymod modstate, bool key\_event);**

## DESCRIPTION

If you want to get the keycode as it would be delivered in key events, including options specified in

**SDL\_HINT\_KEYCODE\_OPTIONS** , then you should pass **key\_event** as true. Otherwise this function simply translates the scancode based on the given modifier state.

## FUNCTION PARAMETERS

- *scancode*

  the desired  **SDL\_Scancode**\
    to query.

- *modstate*

  the modifier state to use when translating the scancode to a keycode.

- *key\_event*

  true if the keycode will be used in key events.

## RETURN VALUE

( **SDL\_Keycode** ) Returns the  **SDL\_Keycode**\
  that corresponds to the given  **SDL\_Scancode** .

## THREAD SAFETY

This function is not thread safe.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetKeyName**(3)](/SDL_GetKeyName/3.md), **•**(3), [**SDL\_GetScancodeFromKey**(3)](/SDL_GetScancodeFromKey/3.md)
