I wanted to make a program that detects if w, a, s, and d
are continuously pressed, to detect if someone is gaming or not. Please let me know if anyone knows if this is possible or not.
Asked
Active
Viewed 172 times
0
-
1Have you looked at pygame? Not sure if this is what you're looking for, but it can detect keystrokes. https://www.pygame.org/docs/ref/key.html – Daniel Sep 12 '21 at 15:18
-
Does this answer your question? [Python method for reading keypress?](https://stackoverflow.com/questions/12175964/python-method-for-reading-keypress) – bad_coder Sep 13 '21 at 23:49
1 Answers
0
You can use the keyboard library And than to detect if one of the keys was pressed, use
import keyboard
for key in "wasd":
keyboard.add_hotkey(key, print, args=[key])
keyboard.wait()
This will print w
, a
, s
or d
if you press one of them.
The keyboard.wait()
is there for the code to not stop running

Bertik23
- 401
- 4
- 9