How do you get pygame to continue to run/look for user input while in the background

193 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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')