Ask coding questions

← Back to all posts
Python Turtle onkeypress() and onkeyrelease()
Four_Of_Clubs (88)

I don't know much about Python or coding in general, so this could just be some ignorance on my part. Disclaimer out of the way, I cant seem to use the functions above. I just get an error saying it has no attribute 'onkeypress()'. Is it not supported or something? Is this normal? Am I just a complete moron and forgot to put some crucial line for setup? Please let me know, Thanks.

YuAndy (14)

Try this:
screen=turtle.Screen() create screen turtle
def up(): create function for onkey
while True:
screen.onkey(up,"Up") screen.onkey(function,key)