title: Arrow key input code not working in tkinter
body: <p>The following is my short script. It is meant to print right left and up when those arrow keys are held, but I don't know why it does not work.</p>
  
  <pre><code>import Tkinter as tk
  
  right = False
  left = False
  up = False
  
  def keyPressed(event):
      if event.keysym == 'Escape':
          root.destroy()
      if event.keysym == 'Right':
          right = True
      if event.keysym == 'Left':
          left = True
      if event.keysym == 'Up':
          up = True
  
  def keyReleased(event):
      if event.keysym == 'Right':
          right = False
      if event.keysym == 'Left':
          left = False
      if event.keysym == 'Up':
          up = False
  
  def task():
      if right:
          print 'Right'
      if left:
          print 'Left'
      if up:
          print 'Forward'
      root.after(20,task)
  
  root = tk.Tk()
  print( "Press arrow key (Escape key to exit):" )
  
  root.bind_all('&lt;Key&gt;', keyPressed)
  root.bind_all('&lt;KeyRelease&gt;', keyReleased)
  root.after(20,task)
  
  root.withdraw()
  root.mainloop()
  </code></pre>
  
  <p>The issue began when I started using <code>root.after()</code>.</p>