from pygame import key
keys = key.get_pressed()
I'm running this on Debian 10, Python 3.7.3, pygame 2.0.1.
- Edit 1:
I assume that using only the "key" module does not require
pygame.init()
because there is notpygame.key.init()
method, but some other modules like "mixer" does. Havingpygame.init()
in the script still results in the same error, with an additional error before that: "error: XDG_RUNTIME_DIR not set in the environment."
@furas also pointed out that I need to define a window for pygame to work, but I'm building a headless system with no GUI so I want to avoid unnecessary memory consumption. Is there a workaround that allows me to use the pygame key module to detect keyboard input without having to create a window?