title: How to use threads to get input from keyboard in python 3?
body: <p>I am making a snake game which requires the player to press the <code>WASD</code> keys without stopping the game process to to get input from player. So I can't use <code>input()</code> for this situation because then the game stops ticking to get input. </p>
  
  <p>I found a <code>getch()</code> function which immediately gives input without pressing enter, but this function also stops game ticking to get input like <code>input()</code>. I decided to use threading module to get input via <code>getch()</code> in different thread. The problem is that getch() isn't working while in different thread and I'm not sure why.</p>
  
  <pre><code>import threading, time
  from msvcrt import getch
  
  key = "lol" #it never changes because getch() in thread1 is useless
  
  def thread1():
      while True:
          key = getch() #this simply is almost ignored by interpreter, the only thing it
          #gives is that delays print() unless you press any key
          print("this is thread1()")
  
  threading.Thread(target = thread1).start()
  
  while True:
      time.sleep(1)
      print(key)
  </code></pre>
  
  <p>So why <code>getch()</code> is useless when it is in <code>thread1()</code>?</p>