Answered by:
KeyboardCapabilities.KeyboardPresent shows undefined
Question
-
I want to get whether there is or isn`t keyboard attached, but it is showing undefined variable all the time!
I used
var keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities(); var temp = keyboardCapabilities.KeyboardPresent;
But it is undefined. After that I tried to log the object, but it turned out to be empty.
Saturday, April 20, 2013 9:21 AM
Answers
-
Besides these problems, I had also lack of memory on my virtual HDD, so I had to reinstall OS and also Visual Studio, and now, it is working!
I don`t know why it wasn`t working before. Maybe there wasn`t such module on my VS?
- Marked as answer by Yanping WangModerator Friday, April 26, 2013 6:22 AM
Saturday, April 20, 2013 3:24 PM
All replies
-
In JavaScript, the case-sensitive property name is keyboardPresent (camel-casing, first character is lower case). Try putting a breakpoint after you create the object and examine it in the Visual Studio debugger (either hovering over the variable name once it's assigned, or using the locals pane at the bottom).
Have you tried the Input Device Capabilities sample? Scenario 2 does the same thing and can be used to double-check.
KraigAuthor, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press
Saturday, April 20, 2013 3:05 PM -
Besides these problems, I had also lack of memory on my virtual HDD, so I had to reinstall OS and also Visual Studio, and now, it is working!
I don`t know why it wasn`t working before. Maybe there wasn`t such module on my VS?
- Marked as answer by Yanping WangModerator Friday, April 26, 2013 6:22 AM
Saturday, April 20, 2013 3:24 PM -
Interesting. Glad it's working now in any case.
Saturday, April 20, 2013 7:34 PM