I'm trying to detect a keypress (for example Space) in Python. Everyone online is referring to the module 'Keyboard'. I've tried to use this, but it will not work. I did install the package and I'm using import keyboard in my first line of code.
I'm using Repl.it to write my code, I don't know if this makes a difference.
Any help is welcome!
This is my code:
import keyboard
keyboard.wait('p')
print('You pressed p')
I'm trying to detect when the user is pressing a certain key. Once the key is pressed, the code continues.
This piece of code does what you ask
ensure that
keywordmodule is installed, othewise install it via pip