title: Holding a key in python
body: <p>I'm writing a simple python code to receive a serial string defining a joystick's position, separate X and Y and do keyboard commands accordingly. </p>
  
  <p>In my code I'm attempting to that, while the user holds the joystick to the right, the -> stays pressed and it's release afterwards. To do this I'm using the <a href="https://github.com/SavinaRoja/PyUserInput" rel="nofollow">PyUserInput</a> library. What happens however is that the right key stays pressed indefinately and the character (Megaman inside an emulator) just runs towads it's death. Could anyone help me figure out why is this happening and how can I fix it?</p>
  
  <pre><code>import serial
  from pykeyboard import PyKeyboard
  
  
  control = PyKeyboard()
  try:
      arduino = serial.Serial('/dev/ttyACM0', 9600)
  except:
      print "Failed to connect on /dev/ACMDUSB0"
  while True:
      xy = arduino.readline()
      if xy is "":
          print ("NULL")
      else:
          x, y = xy.split("_")
          x = int(x)
          y = int(y)
          while(x &gt; 700):
                  control.press_key(control.right_key)
          control.release_key(control.right_key)
          print ("X = {0}\nY = {1}".format(x, y))
  </code></pre>