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
JavaScript
x
8
1
def paddle_a_up():
2
y = paddle_a.ycor()
3
y += 20
4
paddle_a.sety = y
5
6
win.listen()
7
win.onkeypress(paddle_a_up, "Up")
8
I pressed the up arrow and even tried other keys, but it didn’t work.
Advertisement
Answer
Sorry, I just realized my mistake.
JavaScript
1
5
1
def paddle_a_up():
2
y = paddle_a.ycor()
3
y += 20
4
paddle_a.sety = y
5
Here, “sety” was a function, I didn’t call it. Sorry..
paddle_a.sety(y)
fixes my issue