Wor Chan
Wor Chan

Reputation: 169

Simulate keyboard key press in Python to play games on Linux?

I'd like to simulate keyboard events, mainly WASD from Python to control games on Linux.

So far, I've tried PyKey and Keyboard module but unfortunately, they are unable to simulate the keypress in a way that games detect it as continuous movement and so most games just don't work with these.

Are there any alternatives to these modules? Is there something like DirectInput for Linux?

Upvotes: 0

Views: 701

Answers (1)

nb123
nb123

Reputation: 84

You could look into pyautogui and achieve your task with the following sample command: pyautogui.press('w')

I have not tried it for games specifically, but it may work!

Upvotes: 1

Related Questions