> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XINPUT_KEYSTROKE

> XINPUT_KEYSTROKE

# XINPUT\_KEYSTROKE

Describes keystroke data returned by the XInputGetKeystroke function.

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
typedef struct XINPUT_KEYSTROKE {  
    WORD VirtualKey;  
    WCHAR Unicode;  
    WORD Flags;  
    BYTE UserIndex;  
    BYTE HidCode;  
} XINPUT_KEYSTROKE  
```

<a id="membersSection" />

### Members

*VirtualKey*\
Type: WORD

Virtual-key code of the key, button, or stick movement.

*Unicode*\
Type: WCHAR

This member is not used, and its value is zero.

*Flags*\
Type: WORD

Flags that indicate the keyboard state at the time of the input event. This member can be any combination of the following flags:

| Value                      | Description             |
| -------------------------- | ----------------------- |
| XINPUT\_KEYSTROKE\_KEYDOWN | The key was pressed.    |
| XINPUT\_KEYSTROKE\_KEYUP   | The key was released.   |
| XINPUT\_KEYSTROKE\_REPEAT  | A repeat of a held key. |

*UserIndex*\
Type: BYTE

Index of the gamer associated with the headset; a value in the range of 0 to `XUSER_MAX_COUNT - 1`.

*HidCode*\
Type: BYTE

Human Interface Device (HID) code that corresponds to the input. If there's no corresponding HID code, this value is zero.

<a id="remarksSection" />

## Remarks

This structure is used by the [XInputGetKeystroke](/reference/input/xinputongameinput/functions/xinputgetkeystroke) function.

Future devices might return HID codes and virtual-key values that are not supported on current devices and are not defined at this time. Applications should ignore these unexpected values.

A virtual-key code is a byte value that represents a particular physical key on the keyboard, not the character or characters (possibly none) that the key can be mapped to according to the keyboard state. The keyboard state at the time a virtual key is pressed modifies the character reported. For example, `VK_4` might represent "4" or "\$", depending on the state of the Shift key.

A reported keyboard event includes the virtual key that caused the event, whether the key was pressed or released (or is repeating), and the state of the keyboard at the time of the event. The keyboard state indicates whether any Ctrl, Alt, or Shift keys are pressed.

The valid virtual-key codes (VK\_xxx) are defined in XInput.h. In addition to codes that indicate key presses, the following codes indicate controller input:

| Value                      | Description                     |
| -------------------------- | ------------------------------- |
| VK\_PAD\_A                 | **A** button                    |
| VK\_PAD\_B                 | **B** button                    |
| VK\_PAD\_X                 | **X** button                    |
| VK\_PAD\_Y                 | **Y** button                    |
| VK\_PAD\_RSHOULDER         | Right shoulder button           |
| VK\_PAD\_LSHOULDER         | Left shoulder button            |
| VK\_PAD\_LTRIGGER          | Left trigger                    |
| VK\_PAD\_RTRIGGER          | Right trigger                   |
| VK\_PAD\_DPAD\_UP          | Directional pad up              |
| VK\_PAD\_DPAD\_DOWN        | Directional pad down            |
| VK\_PAD\_DPAD\_LEFT        | Directional pad left            |
| VK\_PAD\_DPAD\_RIGHT       | Directional pad right           |
| VK\_PAD\_START             | Start button                    |
| VK\_PAD\_BACK              | Back button                     |
| VK\_PAD\_LTHUMB\_PRESS     | Left thumbstick click           |
| VK\_PAD\_RTHUMB\_PRESS     | Right thumbstick click          |
| VK\_PAD\_LTHUMB\_UP        | Left thumbstick up              |
| VK\_PAD\_LTHUMB\_DOWN      | Left thumbstick down            |
| VK\_PAD\_LTHUMB\_RIGHT     | Left thumbstick right           |
| VK\_PAD\_LTHUMB\_LEFT      | Left thumbstick left            |
| VK\_PAD\_LTHUMB\_UPLEFT    | Left thumbstick up and left     |
| VK\_PAD\_LTHUMB\_UPRIGHT   | Left thumbstick up and right    |
| VK\_PAD\_LTHUMB\_DOWNRIGHT | Left thumbstick down and right  |
| VK\_PAD\_LTHUMB\_DOWNLEFT  | Left thumbstick down and left   |
| VK\_PAD\_RTHUMB\_UP        | Right thumbstick up             |
| VK\_PAD\_RTHUMB\_DOWN      | Right thumbstick down           |
| VK\_PAD\_RTHUMB\_RIGHT     | Right thumbstick right          |
| VK\_PAD\_RTHUMB\_LEFT      | Right thumbstick left           |
| VK\_PAD\_RTHUMB\_UPLEFT    | Right thumbstick up and left    |
| VK\_PAD\_RTHUMB\_UPRIGHT   | Right thumbstick up and right   |
| VK\_PAD\_RTHUMB\_DOWNRIGHT | Right thumbstick down and right |
| VK\_PAD\_RTHUMB\_DOWNLEFT  | Right thumbstick down and left  |

For more information, see [The XInputOnGameInput wrapper](/build/core-features/common/input/porting/input-porting-xinput#xinputWrapperSection).

<a id="requirementsSection" />

## Requirements

**Header:** XInputOnGameInput.h

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

<a id="seealsoSection" />

## See also

[Porting from XInput to GameInput](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XInputGetKeystroke](/reference/input/xinputongameinput/functions/xinputgetkeystroke.md)
- [XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members.md)
- [Porting from XInput to GameInput](/build/core-features/common/input/porting/input-porting-xinput.md)
- [XINPUT_GAMEPAD](/reference/input/xinputongameinput/structs/xinput_gamepad.md)
- [XINPUT_CAPABILITIES](/reference/input/xinputongameinput/structs/xinput_capabilities.md)
