title: How to write a C++ routine which checks which key I've pressed on a keyboard so I can handle each key press separately?
body: <p>I thought several times about this question but I'd always forget to ask. So how can I write a C/C++ routine which checks what key I pressed so the result is returned immediately after the key has been pressed ? How to accomplish that in Windows ? How to accomplish that in Linux ? What headers I should include if I use Dev-C++ and Code::Blocks ?</p>
  
  <p>I try this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  
  int main(void)
  {
      using namespace std ;
      cout &lt;&lt; "Press a key" &lt;&lt; endl ;
      char key ;
      getch() &gt;&gt; key ;
      cout &lt;&lt; "\nYou have pressed: " &lt;&lt; key &lt;&lt; endl ;
      return 0 ;
  }
  </code></pre>
  
  <p>but it doesn't tell me what key I pressed. How to get a key value ?</p>