有没有办法查看物理键盘是否连接到 Windows 8 设备? [英] Is there a way to see if a physical keyboard is attached to a Windows 8 device?

查看:39
本文介绍了有没有办法查看物理键盘是否连接到 Windows 8 设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写 Windows 8 游戏.游戏可在 Windows 7、Windows Phone 和 XBox 上运行.

I'm writing a Windows 8 game. The game runs on Windows 7, Windows Phone, and XBox.

如果连接了键盘,我想显示键盘提示(例如按 Esc 退出")

I want to display keyboard hints if a keyboard is attached (e.g. 'Press Esc to exit')

鉴于 Windows 8 可以是台式机、笔记本电脑或平板电脑,因此可能有也可能没有连接物理键盘.有没有办法以编程方式确定这一点?

Seeing as Windows 8 can be a desktop, laptop, or tablet, there may or may not be a physical keyboard attached. Is there a way to determine this programmatically?

推荐答案

当然,请在此处

private void GetKeyboardProperties()
{
    KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
    KeyboardPresent.Text = keyboardCapabilities.KeyboardPresent != 0 ? "Yes" : "No";
}

或者如果您是 html5/js 开发人员,请查看此处.

or if you html5/js developer take a look here.

这篇关于有没有办法查看物理键盘是否连接到 Windows 8 设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆