Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

windows-8

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?

like image 311
Steve Dunn Avatar asked Jan 01 '13 18:01

Steve Dunn


1 Answers

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.

like image 197
Taras Seredokha Avatar answered Oct 03 '22 22:10

Taras Seredokha