   C++ translate Virtual Keycode to char
  Hi all, I need to convert Virtual Keycodes to chars.Like this: - I push the "A" button- VK = 0x41- Translate 0x41 to A.Is this possible?   
int vk = 0x41;char c = (char) vk;I assume that's too easy and not what you really meant?   ;  In general, you can't. Not for all locales at least. For example, on a german keyboard, the virtual key code for Z produces a "Y" character (or the other way around...)At a minimum, you'll have to handle the WM_CHAR message. That'll give you support for most western languages. If you also want to support east asian languages (Chinese, Japanese, Korean) you'll need to impement support for input method editors, which is a very complex topic...   ;  You also might want to look at the MapVirtualKey() and MapVirtualKeyEx() functions and the WM_UNICHAR message.   ;ToAsciiEx worked for me in the past.;Quote:Original post by CodekaFor example, on a german keyboard, the virtual key code for Z produces a "Y" character (or the other way around...)Both, actually. ;) The two keys are swapped on the keyboard. (Or is that what you meant?)Quote:At a minimum, you'll have to handle the WM_CHAR message. That'll give you support for most western languages. If you also want to support east asian languages (Chinese, Japanese, Korean) you'll need to impement support for input method editors, which is a very complex topic...Yep. WM_CHAR already translates the input into a letter of text (it also accounts for, e.g., the Shift key). WM_KEY* events are for treating the keyboard like a way-overcomplicated console controller, not like a typewriter.   