Rene Schulte
Rene Schulte

Reputation: 2962

Windows 8 WinRT KeyboardCapabilities.KeyboardPresent is always true

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?

Upvotes: 5

Views: 830

Answers (2)

Jacob Morrison
Jacob Morrison

Reputation: 648

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.

Upvotes: 2

Pierre Henri K
Pierre Henri K

Reputation: 278

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.

Upvotes: 1

Related Questions