title: WM_KEYDOWN - capturing keypress causing event
body: <p>I am trying to do a very simple task - have an event occur when a key is pressed - but am having a lot of difficulty implementing it.</p>
  
  <p>I am using the Win32 API. I have been asked what framework I am using but I don't know that. I am using Visual C++ and the program is a Windows program.</p>
  
  <p>All I want to do is have an event occur if a specific key is pressed. For this example I am using the 's' key, and the event is an integer either being set to 1 or 0; whichever it wasn't set to at the time of the key press (I would use bool but I don't know how it works just yet).</p>
  
  <p>I have been told to use GetKeyState(), and then told that this is actually no good. I have also been told to use WM_KEYDOWN but can't work out how this works... Surely what I am doing must be absolute basic programming (keyboard input > output) but I can't get a clear explanation as to how it works?!</p>
  
  <p>I have tried using the following, with no luck:</p>
  
  <pre><code>int Flag;
  if (GetKeyState(115) == 1 &amp;&amp; Flag == 0) Flag = 1;
  if (GetKeyState(115) == 1 &amp;&amp; Flag == 1) Flag = 0;
  </code></pre>
  
  <p>I have also tried using this:</p>
  
  <pre><code>if (GetKeyState(115) &amp; 0x8000 &amp;&amp; Flag == 0) Flag = 1;
  if (GetKeyState(115) &amp; 0x8000 &amp;&amp; Flag == 1) Flag = 0;
  </code></pre>
  
  <p>Neither work. Does anyone know how I could implement WM_KEYDOWN?</p>
  
  <p>I am using a Windows Message Loop</p>