WinRT equivalent for MapVirtualKey
Locked
-
Thursday, February 23, 2012 1:30 AM
Is there an equivalent of MapVirtualKey in WinRT API? I want to convert a virtual key coming in through KeyDown into the equivalent character.
All Replies
-
Thursday, February 23, 2012 7:51 AMModerator
There isn't a direct equivalent. What exactly are you trying to do? MapVirtualKey has several different uses some of which may be achievable in other ways.
--Rob
-
Thursday, February 23, 2012 6:23 PM
I'll describe my use case in the old windows API:
- using a Finnish keyboard layout, I type ä (it is on the key where a US keyboard has a ')
- I receive a window message WM_KEYDOWN with uParam 222
- I pass 222 to MapVirtualKey: UINT character = ::MapVirtualKeyW(222, MAPVK_VK_TO_CHAR);
Result: character == 228 (a.k.a. ä)
If I was using a keyboard with US layout, calling MapVirtualKeyW with 222 would result in character==39 (a.k.a. ')
Thanks,
Jani
- Edited by Jani L Thursday, February 23, 2012 6:23 PM
-
Friday, March 09, 2012 2:49 PM
An answer to Jani's question would be incredibly useful. MapVirtualKey is needed to translate KeyDown event arguments to characters, which currently is a must in Windows RT, because the CharacterReceived event doesn't exist anywhere except on the CoreWindow, and it is called *after* the KeyDown event in the TextBox that will actually process the key.
See also:
http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/f073fa70-1009-4b17-bd92-f6fc7d6f09b1
http://stackoverflow.com/questions/9636168/how-can-i-translate-what-we-get-in-the-keydown-event-to-a-unicode-character
http://stackoverflow.com/questions/9431865/are-there-any-good-resources-on-keyboard-event-handling-in-windows-runtime
- Edited by Ludvig A Norin Friday, March 09, 2012 3:03 PM


