title: How to detect key press event and key hold down event without using pygame
body: <p>I am currently looking for a library that is able to detect/monitor the keyboard. 
  My intention is to detect when a key is being held down and while it occurs something should happen. </p>
  
  <p>Most SO posts suggest to use pygame, but i find it a bit too much, to involve a library such as that for this simple task. i've also tried with <code>pynput</code>, which resulted only detecting one press rather than a stream of presses. </p>
  
  <p>any suggestions on how i can make this while loop detect a key is being pressed / held down...</p>
  
  <p>My attempt with while loop:</p>
  
  <pre><code>from pynput import keyboard
  
  def on_press(key):
      while key == keyboard.Key.cmd_l:
          try:
              print('- Started recording -'.format(key))
          except IOError:
              print "Error"
      else:
          print('incorrect character {0}, press cmd_l'.format(key))
  
  
  def on_release(key):
      print('{0} released'.format(key))
      if key == keyboard.Key.cmd_l:
          print('{0} stop'.format(key))
          keyboard.Listener.stop
          return False
  
  
  
  with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
      listener.join()
  </code></pre>
  
  <p>The while solution make it stuck in the while loop, making it impossible to get out of it. </p>