Skip to content
Open navbar menu
Sign UpLog In
CarterTimmons03

Carter Timmons

@CarterTimmons03
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
How do I use the on_key_press function?
Here is the code and what is shown in the console: image I was trying to follow this tutorial: https://pythonhosted.org/pyglet/programming_guide/key
VulcanWM
VulcanWM
in a function, you can only enter a variable when defining the function (no . in the variable name) why don't you try the code at the starting of the website: def on_key_press(symbol, modifiers): pass def on_key_release(symbol, modifiers): pass `2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
How do I use the OnKey function? I am new to python and cannot figure it out. Thanks :D
VulcanWM
VulcanWM
This might help: https://pythonhosted.org/pyglet/programming_guide/keyboard_events.html2 years ago
CarterTimmons03
CarterTimmons03
I just want todetect when space is presssed2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
I have an animation playing in the console. I want the loop to stop when space is pressed. This could be done by breaking or with a while loop. I do n
Animated Console Test
Python
Geocube101
Geocube101
Try using the getkey module2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
image Why do I receive this error when this code is run? The print command is accurate. I am trying to run two threads at the same time so I can exit
MocaCDeveloper
MocaCDeveloper
Python is very strict with it's indentation. On line 15, you have declared a while loop, which thusly requires you to indent line 16, 16, 18 and 19.2 years ago
VulcanWM
VulcanWM
Do ctrl + a (or cmd + a depending on which type of laptop you are on, if you are on one) and then do tab and then shift + tab2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
I am trying to break out of a loop once the SPACE key is pressed. I was using GetKey but it doesn't let the loop continue until it is executed. from
SixBeeps
SixBeeps
That's because you're calling break. break will always escape the loop. Instead, I think you're looking for continue.2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
This is probably really simple, but how do I install something, such as pip install getkey
StudioHawaii
StudioHawaii
thanks2 years ago
VulcanWM
VulcanWM
some packages are already installed like getkey so in the Python code you just need to do import getkey other packages which are not that popular, so you can either do the pip installing in the shell or do os.system(“pip install package_name”) in the Python code to install the package and import package_name to import it and use it kn your code2 years ago
CarterTimmons03
CarterTimmons03
shared a Post
2 years ago
I am trying to detect when a key is pressed (space), but i cannot figure out how. I have researched it, but every answer does not work and gives me an
MrVoo
MrVoo
Use the getkey module2 years ago