title: How to find which keyboard key has been pressed using GetAsyncKeyState()?
body: <p>I am currently having trouble correctly retrieving some of the keys on a standard keyboard (specifically F keys, arrow keys etc). I am cycling through all 256 ASCII characters using <code>GetAsyncKeyState()</code> on each integer to see if it is pressed, and if so stores it as a char to use in a later <code>SendMessage()</code> function.</p>
  
  <p>this is so that I can allow a user to map a particular key to an Xbox 360 controller button/analog item by using XInput and then send the key to the topmost window when that button/analog item is triggered.</p>
  
  <p>I am aware that the problem lies with hexadecimal/decimal conversion from the virtual key code identified by the <code>GetAsyncKeyState()</code> function as, for example, when I press <kbd>F4</kbd> (hex 73, dec 115) the char is assigned to "s" which in ASCII is the same hex/dec value.</p>
  
  <p>Is Unicode the way forward for this? if so how would I implement this to retrieve the right values for the <code>SendMessage()</code> function?</p>
  
  <p>Below is the loop for <code>GetAsyncKeyState()</code></p>
  
  <pre><code>while (mKey == NULL)
  {
      system("cls");
      cout &lt;&lt; "Press Key" &lt;&lt; endl;
      for (int i = 0; i &lt; 256; i++)
      {
          if (GetAsyncKeyState((i) &amp; SHRT_MAX))
          {
              mKey = i;
          }
      }
  }
  </code></pre>
  
  <p>I am aware <code>system("cls")</code> is bad practice but this console application is only a temporary solution.</p>
  
  <p>Any help you can give will be greatly appreciated :)</p>