Python Forum
[split] can you explain me about addition of keypress to move the turtle..?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] can you explain me about addition of keypress to move the turtle..?
#1
# Keyboard Binding
wn.listen()
wn.onkeypress(paddle_a_up,"w")
wn.onkeypress(paddle_a_down,"s")
wn.onkeypress(paddle_a_left,"a")
wn.onkeypress(paddle_a_right,"d")
can you explain me about addition of keypress to move the turtle..?
thank you
Reply
#2
https://docs.python.org/3.1/library/turt...onkeypress Wrote:turtle.onkeypress(fun, key=None)
Parameters:
  • fun – a function with no arguments or None
  • key – a string: key (e.g. “a”) or key-symbol (e.g. “space”)
Bind fun to key-press event of key if key is given, or to any key-press-event if no key is given. Remark: in order to be able to register key-events, TurtleScreen must have focus. (See method listen().)

>>> def f():
...     fd(50)
...
>>> screen.onkey(f, "Up")
>>> screen.listen()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] keypress isnt working need help jakegold98 1 2,609 Dec-08-2017, 10:16 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020