Interacting with the Keyboard
Almost every control on a form handles its own keyboard input; however, on occasion, you'll want to handle keyboard input directly. For example, you might want to perform an action when the user presses a specific key or releases a specific key. Most controls support three events that you can use to work directly with keyboard input. These are listed in Table 17.4.
Event Name | Description |
---|---|
KeyDown | Occurs when a key is pressed down while the control has the focus. |
KeyPress | Occurs when a key is pressed (the key has been pushed down and then released) while the control has the focus. |
KeyUp | Occurs when a key is released while the control has the focus. |
These events fire in the same ...
Get Sams Teach Yourself Microsoft® Visual C#™ .NET in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.