Detect if keyboard is connected to Windows Surface?

I am trying to detect when the keyboard is attached or detached from the surface. I am currently setting up the function via SetInterval every 1 second and then calling the API to detect the mouse (apparently the keyboard always returns true).

var mouse = new Windows.Devices.Input.MouseCapabilities(). 

Based on the return value, I do my work. Everything is working fine, but slower.

Can I do something else? As if instead of pulling, it's their pushing equivalent to that.

Moving things from Js to Cpp will improve this? If so, how to do it?

thanks

+4
source share
1 answer

Just by looking through the API docs, I think that DeviceWatcher events may be what you are looking for.

+1
source

All Articles