title: Keyboard event handling in Python?
body: <p>So I am not very good with keyboard event handling in Python. I have read the <a href="https://docs.python.org/2/library/curses.html" rel="nofollow">Python Curses</a> tutorial on their official website and looked for answers on SO but it still does not make sense to me. So for starters I want to make a simple program that when it takes a key press such as <code>Escape</code> it prints something simple like <code>You pressed escape!</code>. Sorry I have no code, this is because I do not really know where to start. I think it might have something to do with using functions but I am not sure. You guys do not even have to give me the exact answer but just hints to where I should start! </p>
  
  <p>Heres the code I tried:</p>
  
  <pre><code>from msvcrt import getch
  
  while True:
      key = ord(getch())
      if key == 27: #ESC
          print'You pressed ESC'
  </code></pre>
  
  <p>but it didnt work? Any ideas?</p>