Ludvig A. Norin
Ludvig A. Norin

Reputation: 5325

How can I translate what we get in the KeyDown event to a Unicode character?

The KeyDown event on a TextBox (for example) will process the keyboard event and update the control before the CharacterReceived event is fired on the CoreWindow (in fact, it will do it before the KeyDown event is fired on the CoreWindow as well). The TextBox and other controls also doesn't have any CharacterReceived event.

Because of this it is necessary to handle the TextBox::KeyDown event to perform filtering or other processing of the keyboard events.

The KeyDown event seems to be a direct mapping to the Win32 WM_KEYDOWN message, as it gives us the scancode of the keyboard key pressed and a few other things. In WPF and Win32, we'd use the MapVirtualKey() function to translate the event information to a unicode character.

How do I do this in Windows RT?

Upvotes: 3

Views: 1722

Answers (1)

anonWrkrB
anonWrkrB

Reputation: 355

There's no MapVirtualKey function anymore. The only information I've found on this is that you need to keep track of variables such as the shift key (kanji key, etc for foreign languages) with bools, in the keydown and keyup events, and then make a massive switch case that will take in all of the variables and spit out what you'd want for your app. Here's microsoft's page that outlines some basics:

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868246.aspx

Upvotes: 2

Related Questions