My.Computer.Keyboard 属性

更新:2007 年 11 月

获取一个对象,该对象提供用于访问键盘当前状态(如当前按下了什么键)的属性,并提供用于将击键发送到活动窗口的方法。

' Usage
Dim value As Microsoft.VisualBasic.Devices.Keyboard = My.Computer.Keyboard
' Declaration
Public ReadOnly Property Keyboard As Microsoft.VisualBasic.Devices.Keyboard

返回值

此属性返回计算机的 My.Computer.Keyboard 对象。

备注

使用此属性可轻松地访问 My.Computer.Keyboard 对象。有关更多信息,请参见 My.Computer.Keyboard 对象

示例

此示例使用 My.Computer.Keyboard.CtrlKeyDown 属性来确定当前是否按下了计算机的 Ctrl 键。

If My.Computer.Keyboard.CtrlKeyDown Then
    MsgBox("CTRL key down")
Else
    MsgBox("CTRL key up")
End If

要求

命名空间:Microsoft.VisualBasic.Devices

类:Computer

**程序集:**Visual Basic 运行库(位于 Microsoft.VisualBasic.dll 中)

按项目类型列出的可用性

项目类型

可用

Windows 应用程序

类库

控制台应用程序

Windows 控件库

Web 控件库

Windows 服务

网站

权限

不需要任何权限。

请参见

参考

My.Computer 对象

My.Computer.Keyboard 对象