Managing the Keyboard

You can check for the state of some keyboard keys. My.Computer.Keyboard allows accomplishing this via six properties. Three are about the Caps-lock, Num-lock, and Scroll-lock keys, whereas the other three allow getting the state (pressed or not) of Alt, Shift, and Ctrl. The following code provides a complete example:

image

Get Visual Basic® 2010 Unleashed 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.