How to get the character from the KeyCode?

L

Leif Andersson

Hi all!

I would like to get the character matching the current InputLanguage.
KeyCode 221 is for instance character "[" when US keyboard layout is
choosen, but if the inputlangage is Swedish the character is "å".

How can I get the corresponding character???

Thanks in advance!

Leif Andersson
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Leif,

There is no managed solution for this.
I would suggest you to use KeyPress event where the character comes along
with the event.
Otherwise you can use PInvoke and call ToUnicode, ToUnicodeEx ,
MapVirtualKey, MapVirtualKeyEx or some other keyboard input API.
 
L

Leif Andersson

Stoitcho said:
Hi Leif,

There is no managed solution for this.
I would suggest you to use KeyPress event where the character comes along
with the event.
Otherwise you can use PInvoke and call ToUnicode, ToUnicodeEx ,
MapVirtualKey, MapVirtualKeyEx or some other keyboard input API.

Thanx a lot Stoitcho!

FYI: I used the MapVirtualKey function.
Now I'm get stuck into another problem...

Do you (anyone else) have any suggestion how to do with the special keys
like (US) "[" that will print "{" whent the shift key is pressed?

Looking forward to an answer... :)

Best regards

Leif Andersson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top