title: Python real-time keyboard input
body: <p>I am not looking for <code>input()</code> or <code>raw_input()</code>.  I am looking for what sounds like is available in the msvcrt module, specifically <code>msvcrt.kbhit()</code> and <code>msvcrt.getch()</code>, but am unable to get it working.</p>
  
  <p>I tried example 1, here:</p>
  
  <p><a href="http://effbot.org/librarybook/msvcrt.htm" rel="nofollow noreferrer">http://effbot.org/librarybook/msvcrt.htm</a></p>
  
  <p>and the chosen answer here:</p>
  
  <p><a href="https://stackoverflow.com/questions/22365473/python-windows-msvcrt-getch-only-detects-every-3rd-keypress">Python Windows `msvcrt.getch()` only detects every 3rd keypress?</a></p>
  
  <p>both of which put me into infinite loops from which I am unable to escape by pressing 'esc' and 'q' respectively.</p>
  
  <pre><code>import msvcrt
  while True:
      pressedKey = msvcrt.getch()
      if pressedKey == 'x':    
         break
  </code></pre>
  
  <p>I would like to avoid downloading and installing new modules, like pyhook suggested below, if possible:</p>
  
  <p><a href="https://stackoverflow.com/questions/13694873/how-do-i-get-realtime-keyboard-input-in-python">How do I get realtime keyboard input in Python?</a></p>