I’m looking to make my game work In the background and if WASD is clicked to move the character on the screen regardless if the window for the program is selected or not. To better clarify I’m looking to use an application and simultaneously have my game update the players location if the other application clicks the buttons W,A,S, or D.
Asked
Active
Viewed 115 times
0
-
You can use other libraries which dont need an window and if needed use a pygame window at the same time. – Jerry Aug 10 '22 at 07:54
-
The libraries `pynput` and `keyboard` might help you. A pygame window can't detect keys when it's not selected. – Jerry Aug 10 '22 at 08:06
-
thanks jerry I have uploaded what I came up with but cant get out the bugs if you had any input. https://stackoverflow.com/questions/73333872/can-any-one-tell-me-why-no-matter-what-i-do-i-cant-get-the-dot-to-move – michael white Aug 12 '22 at 12:05
1 Answers
0
You can use keyboard for it:
pip install keyboard
import keyboard
# This will detect q key press.
# And returns True/False.
# You need to put this code inside you game loop.
keyboard.is_pressed('q')

Sarper Makas
- 99
- 8