title: Python-Turtle - Moving the turtle by holding down a key: releasing the key moves the turtle back instead of stopping it
body: <p>I'm writing a program that moves the turtle in different directions by pressing down the arrow keys. I want the ability to move it in a particular direction by holding down the respective arrow key instead of pressing it repeatedly. However, when I release the arrow key after holding it down for few seconds, the turtle is moving back a bit instead of stopping immediately. The amount by which it moves back depends on how long I held down the key to move it.</p>
  <p>Can you help me to solve this issue or suggest another way to implement this with the turtle module?</p>
  <p>Note: I observed that when I hold down the key, the line is not drawn until I release it. I'm not sure if it's expected or related to this issue.</p>
  <p>Note 2: I'm using the onkeypress method for handling the &quot;holding down the key&quot; event. I tried using the onkeyrelease(None, arrow_key) method to solve this, but it doesn't work either.</p>
  <p>Here is my code:</p>
  <pre><code>from turtle import Turtle, Screen
  
  
  def move_right():
      turtle.setheading(0)
      turtle.forward(25)
  
  
  def move_up():
      turtle.setheading(90)
      turtle.forward(25)
  
  
  def move_left():
      turtle.setheading(180)
      turtle.forward(25)
  
  
  def move_down():
      turtle.setheading(270)
      turtle.forward(25)
  
  turtle = Turtle()
  screen = Screen()
  
  screen.onkeypress(move_right, &quot;Right&quot;)
  screen.onkeypress(move_up, &quot;Up&quot;)
  screen.onkeypress(move_left, &quot;Left&quot;)
  screen.onkeypress(move_down, &quot;Down&quot;)
  screen.listen()
  screen.exitonclick()
  </code></pre>