Steve Dunn
Steve Dunn

Reputation: 21761

Is there a way to see if a physical keyboard is attached to a Windows 8 device?

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

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

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?

Upvotes: 9

Views: 9268

Answers (1)

Taras Seredokha
Taras Seredokha

Reputation: 372

Of course, please read this quick start here

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

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

Upvotes: 9

Related Questions