title: Python - detect keypress in shell
body: <p>Trying to detect and respond to key presses in Python. Am using IDLE and Python 3.3. I have the following code so far</p>
  
  <pre><code>import msvcrt
  
  while True:
     inp = ord(msvcrt.getch())
  
     if (inp != 255):
        print(inp)
  </code></pre>
  
  <p>I have the IF statement because if I just allow the script to throw out the value of 'inp' it just spoons out 255 repeatedly. So I threw in the if statement to respond to anything but 255 and now when run the code does nothing but output the actual keypress character in the shell. </p>