title: Asynchronous keyboard input on win32
body: <p>I'm creating a simple 3D game on Windows 7 in C++ using the free version of the Havok physics engine. I want to use the WASD keys to move the character. The structure of the code is such that I need to capture this input asychronously; there is a function called in every frame of the scene to update the character's position (I want to try checking if a key is currently pressed instead of using some kind of listener for events). I searched around for a good solution, as I know little to nothing about win32 functions, and put this together:</p>
  
  <pre><code>if (GetAsyncKeyState(0x41) &amp; 0x8000) posX=-1.0f; //A
  if (GetAsyncKeyState(0x44) &amp; 0x8000) posX=1.0f;  //D
  if (GetAsyncKeyState(0x57) &amp; 0x8000) posX=1.0f;  //W
  if (GetAsyncKeyState(0x53) &amp; 0x8000) posX=-1.0f; //S
  </code></pre>
  
  <p>After checking with some printf statements, the visual debugger doesn't seem to be picking up any input with this. I know of WM_KEYDOWN and WM_KEYUP, but I can't find simple explanations on how to use them, and as far as I can tell they are more event-based than asynchronous.</p>
  
  <p>Is there a problem with the snippet above, or should I try another approach?</p>