mouse&keyboard events
how the heck i am suppesd to do mouse and keyboard events?
someone pls help its for a test
Voters
AllAwesome497
Please provide more context to this question, we don't know exactly what you are asking what to do.
how the heck i am suppesd to do mouse and keyboard events?
someone pls help its for a test
Please provide more context to this question, we don't know exactly what you are asking what to do.
Key Events
You can do key events in turtle by doing
screen.onkey(callback, key)
. Switch out the callback for the function you want to do when the key is pressed (without the()
), and the key to a string that represents the key you want to get the event for.E.g
Mouse Events
You can do mouse events in turtle by doing
screen.onclick(callback)
. Similarly to the key events, the callback will be the function to call when the screen is clicked (without the()
). You will get an x and y coordinate when the function is called, so make sure you allow those arguments to be parsed in.E.g
Note: Make sure to add
turtle.listen()
before your events to be able to use them.