Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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).
Windows Forms provides two events that occur when a user presses a keyboard key and one event when a user releases a keyboard 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.
The following table describes the three keyboard events.
Keyboard event | Description | Results |
---|---|---|
KeyDown | This event is raised when a user presses a physical key. | The handler for KeyDown receives:
|
KeyPress | 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. | KeyPress is raised after KeyDown.
|
KeyUp | This event is raised when a user releases a physical key. | The handler for KeyUp receives:
|
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now