Python Forum

Full Version: why can't i used ESC key??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this is my code
import turtle as t

def blank():
    t.clear()


t.speed(0)
t.pensize(2)
t.shape("turtle")
t.onscreenclick(t.goto)
t.onkeypress(blank, "Escape")
why can't i used ESC key??
You need to get turtle to listen to events, and you need to start turtle's event processing loop. Put these at the end of your code:

t.listen()
t.mainloop()