How do I use PyAutoGUI to detect a keypress event? In my research, I could not make an example in this model:
import pyautogui
num = 0
if pyautogui.press('b'): # I know the right thing is not to use the press, but, what do I put in place?
num = 1
Detecting keystrokes isn't possible in PyAutoGUI. You might want to try the Pynput module instead: https://pypi.org/project/pynput/
The python keyboard library provides the exact function you need:
import keyboard
if keyboard.is_pressed('b'):
num = 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With