title: How to properly end a while loop using a key press?
body: <p>i am trying to create a while loop that will run until keypress.
  I am using this code:</p>
  
  <pre><code>while (System.in.available() == 0){
              // do something
      }
  </code></pre>
  
  <p>unfortunately, this is not working.
  is there any way around it? what could be the reason for this?
  i should mention that during the loop i am printing things to the console, could this be the reason?</p>
  
  <p>any help would be appreciated, thank you for your help.</p>