Interacting with the Keyboard
Most every control 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 button or releases a specific button. Most controls support three events that you can use to work directly with keyboard input. These are listed in Table 18.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 C#™ 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.