WinRT equivalent for MapVirtualKey


  • Is there an equivalent of MapVirtualKey in WinRT API? I want to convert a virtual key coming in through KeyDown into the equivalent character.

    Thursday, February 23, 2012 1:30 AM

All replies

  • 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.


    Thursday, February 23, 2012 7:51 AM
  • I'll describe my use case in the old windows API:

    1. using a Finnish keyboard layout, I type ä (it is on the key where a US keyboard has a ')
    2. I receive a window message WM_KEYDOWN with uParam 222
    3. 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. ')



    • Edited by Jani L Thursday, February 23, 2012 6:23 PM
    Thursday, February 23, 2012 6:23 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: 

    Friday, March 9, 2012 2:49 PM