Redigera

Dela via


Keyboard Class

Definition

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.

public ref class Keyboard
public class Keyboard
type Keyboard = class
Public Class Keyboard
Inheritance
Keyboard

Examples

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

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.

Tasks

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)

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

Constructors

Keyboard()

Initializes a new instance of the Keyboard class.

Properties

AltKeyDown

Gets a value that indicates whether the ALT key is down.

CapsLock

Gets a value that indicates whether CAPS LOCK is turned on.

CtrlKeyDown

Gets a value that indicates whether a CTRL key is down.

NumLock

Gets a value that indicates whether the NUM LOCK key is on.

ScrollLock

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

ShiftKeyDown

Gets a value that indicates whether a SHIFT key is down.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SendKeys(String, Boolean)

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

SendKeys(String)

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)

Applies to

See also