Keyboard Class
Provides properties for accessing the current state of the keyboard, such as what keys are currently pressed, and provides a method to send keystrokes to the active window.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
| Name | Description | |
|---|---|---|
![]() | Keyboard() | Initializes a new instance of the Keyboard class. |
| Name | Description | |
|---|---|---|
![]() | AltKeyDown | Gets a Boolean indicating if the ALT key is down. |
![]() | CapsLock | Gets a Boolean indicating if CAPS LOCK is turned on. |
![]() | CtrlKeyDown | Gets a Boolean indicating if a CTRL key is down. |
![]() | NumLock | Gets a Boolean indicating if the NUM LOCK key is on. |
![]() | ScrollLock | Gets a Boolean indicating whether the SCROLL LOCK key is on. |
![]() | ShiftKeyDown | Gets a Boolean indicating if a SHIFT key is down. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | SendKeys(String^) | Sends one or more keystrokes to the active window, as if typed on the keyboard. |
![]() | SendKeys(String^, Boolean) | Sends one or more keystrokes to the active window, as if typed on the keyboard. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The My.Computer.Keyboard object provides an interface to the computer's keyboard. The properties of the My.Computer.Keyboard provide information about the state of several special keys. The My.Computer.Keyboard.SendKeys method lets you send keys to the active window as if they have been typed at the keyboard.
The following table lists an example of a task involving the My.Computer.Keyboard object.
To | See |
Send keystrokes to an application | How to: Start an Application and Send it Keystrokes (Visual Basic) |
Project type | Available |
Windows Application | Yes |
Class Library | Yes |
Console Application | Yes |
Windows Control Library | Yes |
Web Control Library | No |
Windows Service | Yes |
Web Site | No |
This example uses the My.Computer.Keyboard.CtrlKeyDown property to determine if the computer's CTRL key is pressed.
If My.Computer.Keyboard.CtrlKeyDown Then MsgBox("CTRL key down") Else MsgBox("CTRL key up") End If
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


