title: How do I clean input buffer before using getch()?
body: <p>So, I am using GetAsyncKeyState() to see when some key is pressed. But, after using it I need to use getch(). But it seems that getch() gets whatever GetAsyncKeyState() got before again. That is the version of my simplified code:</p>
  
  <pre><code>#include &lt;graphics.h&gt;
  
  int main()
  {
      initwindow(100, 100);
  
      while(true)
      {        
          if (GetAsyncKeyState(VK_RETURN))    //wait for user to press "Enter"
              break;
          //do other stuff
      }
  
      getch();    //this is just skipped
  
      return 0;
  }
  </code></pre>
  
  <p>I think I need to clean the input buffer before using getch(). But how?
  PS: GetAsyncKeyState() is a must-use for me and I have not found any substitute for getch(), which could work with BGI window and which would fix the problem.
  Hoping for some advice and thank you.</p>