locked
How to get the Unicode from a on screen keyboard event

    Question

  • I'm working on an app which has to catch the keyboard events and get the keycode or the unicode of the key.  On the SwapChainBackground page, since the SwapChainBackground can not get a focus and then can not catch a keyboard event I try to catch the keyboard events by Winodw::Current->CoreWindow->keyDown and keyUp.  But I find for some special keys they will always give me a VirtualKey 231.  I know it's VK_PACKET.  For a JS app, we can get the unicode by calling e.char.charCodeAt(0), but how can I get the unicode in C++ app ?

    I saw Rob wrote this on this topic:

    http://social.msdn.microsoft.com/Forums/windowsapps/en-US/b0166400-b55c-4772-a0c1-d29c7c84812c/onscreen-keyboard-does-not-provide-scancode-on-the-keydown-event

    It seems we can not directly get the unicode from a CoreWindow keybaord event, am I right ?  Thanks.

    Thursday, August 29, 2013 2:12 AM

Answers

  • I believe the bug referenced in the previous thread was fixed for Windows 8 release (I don't have a Win8 system handy to test on: I just verified that it no longer reproduces in Windows 8.1). In that case the soft keyboard passed VK_PACKET for all characters, not just for ones which couldn't map to normal keys.

    In general characters in that range are much more interesting as characters (delivered via the CharacterReceived event) rather than as Keys. You will be able to get the actual characters by listening to CharacterReceived.

    --Rob

    Thursday, August 29, 2013 2:40 AM
    Owner

All replies

  • I believe the bug referenced in the previous thread was fixed for Windows 8 release (I don't have a Win8 system handy to test on: I just verified that it no longer reproduces in Windows 8.1). In that case the soft keyboard passed VK_PACKET for all characters, not just for ones which couldn't map to normal keys.

    In general characters in that range are much more interesting as characters (delivered via the CharacterReceived event) rather than as Keys. You will be able to get the actual characters by listening to CharacterReceived.

    --Rob

    Thursday, August 29, 2013 2:40 AM
    Owner
  • Hi, Rob, in fact I have to catch the keyboard events and sent them to remote side,  this is part of remote control just like remote desktop. So what I have to do is events redirection.  I will try to get characterReceived event and then simulate keyboard events.  Thanks.
    Thursday, August 29, 2013 5:45 AM