Skip to content
Advertisement

Turtle onkeypress function not taking input

I was watching a video where the Turtle module was being used for making a Pong game. But the onkeypress function isn’t taking inputs, even after clicking on the window of Pong.

OS: Ubuntu 20.04 LTS

def paddle_a_up():
    y = paddle_a.ycor()
    y += 20
    paddle_a.sety = y

win.listen()
win.onkeypress(paddle_a_up, "Up")

I pressed the up arrow and even tried other keys, but it didn’t work.

Advertisement

Answer

Sorry, I just realized my mistake.

def paddle_a_up():
    y = paddle_a.ycor()
    y += 20
    paddle_a.sety = y

Here, “sety” was a function, I didn’t call it. Sorry..

paddle_a.sety(y) fixes my issue

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement