Is there a way to get all keyboard input from turtle in python not just specific keys. I am aware I can use turtle.onkey(up, "Up")
to call a function on a specific key press but I want to be able to get any key press without having to go through and manually set a function for every single key as I want to be able to display user text input in the turtle window directly without having to use console or alternatives like that.
Asked
Active
Viewed 64 times
0
-
Just make a for loop and you register all the keys? Keys are mapped to integers... check on internet the max value for keys and simply pass that to the onkey function – Volzy Nov 14 '22 at 23:18
-
Maybe [Update turtle/gui while waiting for input python](https://stackoverflow.com/questions/23620960/update-turtle-gui-while-waiting-for-input-python/73589137#73589137) solves the problem for you? The behavior expected here is rather vague – ggorlen Nov 15 '22 at 01:08
1 Answers
1
the answer is no, you can't do it only with turtle, turtle built with tkinter and tkinter don't have that option, if you want to do it you should import other modules like pyinput, but pyinput may not that easy to learn (I didn't really try) I just use the module "keyboard" (to download it on windows go to command prompt and type pip install keyboard) but I didn't try all of the functions with that module and I don't know if it is fully trusted, I just use it for one simple function which is
from keyboard import is_pressed as pressed
if keyboard.pressed('h'): # just for example it should be a string
# what ever you want to do here
so I really recommended to just learn pyinput cause it is really has more options, but if you don't use a lot of options you can do like me.

TheGreenLightning444
- 46
- 4