Python Forum
why can't i used ESC key?? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: why can't i used ESC key?? (/thread-17273.html)



why can't i used ESC key?? - dongk33 - Apr-04-2019

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??


RE: why can't i used ESC key?? - ichabod801 - Apr-04-2019

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()