title: Implementing a KeyPress Event in C
body: <p>I have a infinite loop like the following one, and within this loop, I want to continuously check the keyboard to see if the escape key (ESC) has been pressed or not. If it is pressed, then the loop should be broken. How I can do this in C? (I am using gcc, and do access to pthreads as well in case this must be done via threads)</p>
  
  <pre><code> while(1){
          //do something
          //check for the ESC key
   }
  </code></pre>