Keyboard Class

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.

Namespace:   Microsoft.VisualBasic.Devices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

System.Object
  Microsoft.VisualBasic.Devices.Keyboard

[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
public class Keyboard

NameDescription
System_CAPS_pubmethodKeyboard()

Initializes a new instance of the Keyboard class.

NameDescription
System_CAPS_pubpropertyAltKeyDown

Gets a Boolean indicating if the ALT key is down.

System_CAPS_pubpropertyCapsLock

Gets a Boolean indicating if CAPS LOCK is turned on.

System_CAPS_pubpropertyCtrlKeyDown

Gets a Boolean indicating if a CTRL key is down.

System_CAPS_pubpropertyNumLock

Gets a Boolean indicating if the NUM LOCK key is on.

System_CAPS_pubpropertyScrollLock

Gets a Boolean indicating whether the SCROLL LOCK key is on.

System_CAPS_pubpropertyShiftKeyDown

Gets a Boolean indicating if a SHIFT key is down.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSendKeys(String)

Sends one or more keystrokes to the active window, as if typed on the keyboard.

System_CAPS_pubmethodSendKeys(String, Boolean)

Sends one or more keystrokes to the active window, as if typed on the keyboard.

System_CAPS_pubmethodToString()

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

.NET Framework
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.

Return to top
Show:
© 2016 Microsoft