Windows 8 WinRT KeyboardCapabilities.KeyboardPresent is always true

空扰寡人 提交于 2020-06-14 06:49:35

问题


We are using KeyboardCapabilities.KeyboardPresent to test if a keyboard is connected to a device:

bool hasKeyboard = new KeyboardCapabilities().KeyboardPresent == 1;

Unfortunately it's always TRUE regardless if a bluetooth keyboard is connected or not. We tried it with the following hardware:

Dell Vostro 470 is a desktop PC with wireless Bluetooth keyboard which has power ON/OFF options. http://www.dell.com/in/business/p/vostro-470/pd

Samsung 700T Notebook (Slate) http://www.samsung.com/uk/consumer/pc-peripherals/slate-pc/slate-pc/XE700T1A-A01UK

Switching off the keyboard, bluetooth, removing the keyboard from the devices list, etc. didn't help, KeyboardCapabilities.KeyboardPresent always returns 1.

Are we missing something here or is there an API which we should use instead to detect such changes?


回答1:


Also having this issue, on my Microsoft Surface(which has a detachable keyboard), the KeyboardPresent always returns a '1', even if no keyboard(touch/type cover) is attached and we have the software keyboard open.




回答2:


I have the same behavior on my tablet. Might be a bug...

A more complex solution is to enumerate device containers. It will tell you if any keyboard is connected. For more details, refer to the Device enumeration sample.



来源:https://stackoverflow.com/questions/12841218/windows-8-winrt-keyboardcapabilities-keyboardpresent-is-always-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!