title: C# clearing key buffer
body: <p>I have a console game where the player selects and ability by pressing a number, the ability is done to the enemy, we wait 2 seconds then the enemy does his ability to the player, then we wait 2 seconds again and we start over. I find that if the player presses a key for an ability while this waiting is going on on the next loop it'll do it right away (the key press is sitting in the buffer). I want to clear that buffer at the start of each loop.</p>
  
  <p>I tried the following but it never comes back from the Peek() call.</p>
  
  <pre><code>private void FlushKeyboard()
  {
     while (Console.In.Peek() != -1)
          Console.In.Read();
  }
  </code></pre>