My.Computer.Keyboard Object

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.

Remarks

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.

Task

The following table lists examples of tasks involving the My.Computer.Keyboard object.

To

See

Check if CAPS LOCK is on

How to: Determine If CapsLock is On in Visual Basic

Send keystrokes to an application

How to: Start an Application and Send it Keystrokes (Visual Basic)

Example

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

Requirements

Namespace:Microsoft.VisualBasic.Devices

Class:Keyboard

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

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

See Also

Concepts

Accessing the Keyboard

Reference

My.Computer.Keyboard Object Members

My.Computer Object

Microsoft.VisualBasic.Devices.Keyboard