   Converting virtual key codes into ASCII chars
  How do I convert a virtual key code (EG. VK_SPACE), into a symbol which takes into account the current state modifier keys (ctrl, ect.), and spits out the character? For example, pressing just the 'a' key will yield 'a', which shift and 'a' will yield 'A', but pressing the escape key will yield nothing, as will pressing ctrl, alt, or shift by themselves. I am storing all my key states in an array (int KeyStes[256]), and updating them each frame.BTW: I am using win32 (obviosly). Any help is much appreciated.   
struct VK_String_Table{    std::vector<std::string> Table;    VK_String_Table();};VK_String_Table::VK_String_Table(){    #define AddString(S) Table.push_back(std::string(S))    AddString("--0");    AddString("Left Mouse");    AddString("Right Mouse");    AddString("BREAK");    AddString("Middle Mouse");    AddString("X1 Mouse");    AddString("X2 Mouse");    AddString("--7");    AddString("Backspace");    AddString("Tab");    AddString("--10");    AddString("--11");    AddString("Clear");    AddString("Enter");    AddString("--14");    AddString("--15");    AddString("Shift");AddString("Ctrl");AddString("Alt");    AddString("Pause");    AddString("Caps");    AddString("Hanguel");    AddString("--22");    AddString("Junja");    AddString("final");    AddString("Hanja");    AddString("--26");    AddString("Esc");    AddString("convert");    AddString("non-convert");    AddString("accept");    AddString("mode change request");    AddString("Space");    AddString("PageUp");    AddString("PageDown");    AddString("End");    AddString("Home");    AddString("Left");    AddString("Up");    AddString("Right");    AddString("Down");    AddString("Select");    AddString("Print");    AddString("Execute");    AddString("PrintScr");    AddString("Ins");    AddString("Del");    AddString("Help");    AddString("0");    AddString("1");    AddString("2");    AddString("3");    AddString("4");    AddString("5");    AddString("6");    AddString("7");    AddString("8");    AddString("9");    AddString("--58");   AddString("--59");    AddString("--60");    AddString("--61");    AddString("--62");    AddString("--63");    AddString("--64");    AddString("A");    AddString("B");    AddString("C");    AddString("D");    AddString("E");    AddString("F");    AddString("G");    AddString("H");    AddString("I");    AddString("J");    AddString("K");    AddString("L");    AddString("M");    AddString("N");    AddString("O");    AddString("P");    AddString("Q");    AddString("R");    AddString("S");    AddString("T");    AddString("U");    AddString("V");    AddString("W");    AddString("X");    AddString("Y");    AddString("Z");    AddString("L_WIN");    AddString("R_WIN");    AddString("APPS");    AddString("--94");    AddString("Sleep");    AddString("Num 0");    AddString("Num 1");    AddString("Num 2");    AddString("Num 3");    AddString("Num 4");    AddString("Num 5");    AddString("Num 6");    AddString("Num 7");    AddString("Num 8");    AddString("Num 9");    AddString("Num *");    AddString("Num +");    AddString("Separator");    AddString("Num -");    AddString("Num .");    AddString("Num /");    AddString("F1");    AddString("F2");    AddString("F3");    AddString("F4");    AddString("F5");    AddString("F6");    AddString("F7");    AddString("F8");    AddString("F9");    AddString("F10");    AddString("F11");    AddString("F12");    AddString("F13");    AddString("F14");    AddString("F15");    AddString("F16");    AddString("F17");    AddString("F18");    AddString("F19");    AddString("F20");    AddString("F21");    AddString("F22");    AddString("F23");    AddString("F24");    AddString("--136");    AddString("--137");    AddString("--138");    AddString("--139");    AddString("--140");    AddString("--141");    AddString("--142");    AddString("--143");    AddString("Num Lock");    AddString("Scroll Lock");    AddString("--146");    AddString("--147");    AddString("--148");    AddString("--149");    AddString("--150");    AddString("--151");    AddString("--152");    AddString("--153");    AddString("--154");    AddString("--155");    AddString("--156");    AddString("--157");    AddString("--158");    AddString("--159");    AddString("LShift");    AddString("Rshift");    AddString("LCrtl");    AddString("RCtrl");    AddString("LMenu");    AddString("RMenu");    AddString("Browser Back");    AddString("Browser Forward");    AddString("Browser Refresh");    AddString("Browser Stop");    AddString("Browser Search");    AddString("Browser Favorites");    AddString("Browser Home");    AddString("Volume Mute");    AddString("Volume Down");    AddString("Volume Up");    AddString("Next Track");    AddString("Previous Track");    AddString("Stop Media");    AddString("Play/Pause Media");    AddString("Start Mail");    AddString("Select Media");    AddString("Start Application 1");    AddString("Start Application 2");    AddString("--184");    AddString("--185");    AddString(";");    AddString("=");    AddString(",");    AddString("-");    AddString(".");    AddString("/");    AddString("~");    AddString("--193");    AddString("--194");    AddString("--195");    AddString("--196");    AddString("--197");    AddString("--198");    AddString("--199");    AddString("--200");    AddString("--201");    AddString("--202");    AddString("--203");    AddString("--204");    AddString("--205");    AddString("--206");    AddString("--207");    AddString("--208");    AddString("--209");    AddString("--210");    AddString("--211");    AddString("--212");    AddString("--213");    AddString("--214");    AddString("--215");    AddString("--216");    AddString("--217");    AddString("--218");    AddString("[");    AddString("\\");    AddString("]");    AddString("'");  AddString("--223");    AddString("--224");    AddString("--225");    AddString("--226");    AddString("--227");    AddString("PROCESSKEY");    AddString("--229");    AddString("PACKET");    AddString("--231");    AddString("Nokia RESET");    AddString("Nokia JUMP");    AddString("Nokia PA1");    AddString("Nokia PA2");    AddString("Nokia PA3");    AddString("Nokia WSCTRL");    AddString("Nokia CUSEL");    AddString("Nokia ATTN");    AddString("Nokia FINNISH");    AddString("Nokia COPY");    AddString("Nokia AUTO");    AddString("Nokia ENLW");    AddString("Nokia BACKTAB");    AddString("Attn");    AddString("CrSel");    AddString("ExSel");    AddString("Erase EOF");    AddString("Play");    AddString("Zoom");    AddString("NONAME");    AddString("PA1");    AddString("Clear ");    AddString("Multimedia");    #undef AddString}The "--#" entries are undefined or reserved virtual keys.std::string LookUpVK_STD_String(int VK_Code){    std::string error("Virtual Key code out of range");    static const VK_String_Table VK_Codes;    if(VK_Code >= VK_Codes.Table.size() || VK_Code < 1)   return error;    else    return VK_Codes.Table[VK_Code];}*/That doesn’t exactly answer your problem, but it should get you started. What you need to do is have two tables that hold the alternate characters of each key. Then check the state modifier keys when a character key is pressed and decide which table to get your characters from. if Shift is head down get characters from the table that holds 'A', 'B', 'C', '!', '@', '#' else get them from the table that holds 'a', 'b', 'c', '1', '2', '3'   ;  Have a look at ToAscii().;  @Grain:Thanks for the reply, but that doesn't really help me solve my problem. Let me try and reiterate what I said above. What I need to do, is, well, pretty much achieve what the following code does:switch (iMsg){case WM_CHAR:return wParam;} ...Except without the reliance on the wParam and iMsg variables.@Dave Hunt: Thanks, I'l take a look at it.   ;  Grain, thanks for the help, I read your updated post. I see where you are coming from, but is there a more automated way of doing this?   ;Quote:Original post by Dave HuntHave a look at ToAscii().I second that.  I had a heap of trouble trying to use WM_CHAR messages so I instead maintained a keyboard state buffer and used ToAscii with WM_KEYUP and WM_KEYDOWN messages.  That worked really well.   ;  Oh goodness. The only correct solution is to use WM_CHAR. Read the MSDN entry for how to use it properly (all you need to do to make it work is use TranslateMessage in your message pump).Links: WM_CHAR, TranslateMessage.If you look at a NeHe's lesson 1, it's got the code for a message pump with TranslateMessage (although he dosn't use WM_CHAR there).   