My.Computer.Keyboard Object
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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.

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 examples of tasks involving the My.Computer.Keyboard object.

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")
    MsgBox("CTRL key up")
End If

Namespace: Microsoft.VisualBasic.Devices

Class: Keyboard

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

Availability by Project Type

Project type Available

Windows Application


Class Library


Console Application


Windows Control Library


Web Control Library


Windows Service


Web Site


© 2015 Microsoft