--- title: "Using keyboard events" description: Overview of using keyboard events to handle keyboard input. This article provides a list of keyboard-related events and when to use them. ms.date: 10/26/2020 ms.topic: overview dev_langs: - "csharp" - "vb" helpviewer_keywords: - "KeyPress event [Windows Forms]" - "keyboards [Windows Forms], keyboard events" - "KeyUp event" - "KeyDown event" - "keyboard events" - "events [Windows Forms], keyboard" --- # Using keyboard events (Windows Forms .NET) Most Windows Forms programs process keyboard input by handling the keyboard events. This article provides an overview of the keyboard events, including details on when to use each event and the data that is supplied for each event. For more information about events in general, see [Events overview (Windows Forms .NET)](../forms/events.md). [!INCLUDE [desktop guide under construction](../../includes/desktop-guide-preview-note.md)] ## Keyboard events Windows Forms provides two events that occur when a user presses a keyboard key and one event when a user releases a keyboard key: - The event occurs once. - The event, which can occur multiple times when a user holds down the same key. - The event occurs once when a user releases a key. When a user presses a key, Windows Forms determines which event to raise based on whether the keyboard message specifies a character key or a physical key. For more information about character and physical keys, see [Keyboard overview, keyboard events](overview.md#keyboard-events). The following table describes the three keyboard events. |Keyboard event|Description|Results| |--------------------|-----------------|-------------| ||This event is raised when a user presses a physical key.|The handler for receives:

  • A parameter, which provides the property (which specifies a physical keyboard button).
  • The property (SHIFT, CTRL, or ALT).
  • The property (which combines the key code and modifier). The parameter also provides:

    • The property, which can be set to prevent the underlying control from receiving the key.
    • The property, which can be used to suppress the and events for that keystroke.
| ||This event is raised when the key or keys pressed result in a character. For example, a user presses SHIFT and the lowercase "a" keys, which result in a capital letter "A" character.| is raised after .

  • The handler for receives:
  • A parameter, which contains the character code of the key that was pressed. This character code is unique for every combination of a character key and a modifier key.

    For example, the "A" key will generate:

    • The character code 65, if it is pressed with the SHIFT key
    • Or the CAPS LOCK key, 97 if it is pressed by itself,
    • And 1, if it is pressed with the CTRL key.
| ||This event is raised when a user releases a physical key.|The handler for receives:

  • A parameter:

    • Which provides the property (which specifies a physical keyboard button).
    • The property (SHIFT, CTRL, or ALT).
    • The property (which combines the key code and modifier).
| ## See also - [Overview of using the keyboard (Windows Forms .NET)](overview.md) - [How to modify keyboard key events (Windows Forms .NET)](how-to-change-key-press.md) - [How to Check for modifier key presses (Windows Forms .NET)](how-to-check-modifier-key.md) - [How to simulate keyboard events (Windows Forms .NET)](how-to-simulate-events.md) - [How to handle keyboard input messages in the form (Windows Forms .NET)](how-to-handle-forms.md)