Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How to translate virtual keycode to char?

I am trying to map a virtual keycode to a char.

My code uses ProcessCmdKey to listen to WM_KEYDOWN which gives me access to the key pressed. For example, when I press single quote I get a key of 222 which I want to have it mapped to keychar 39 which represents... you guessed it... single quote.

My dev context is: - .net Framework 2.0 - UserControl placed in a lot of places

Do you know the answer to the question?

like image 803
Horas Avatar asked Nov 25 '08 20:11

Horas


1 Answers

Isn't that what the System.Windows.Form.KeysConverter class is for?

KeysConverter kc = new KeysConverter(); string keyChar = kc.ConvertToString(keyData); 
like image 51
Powerlord Avatar answered Sep 22 '22 07:09

Powerlord