moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

keyboard controller press function does not work as expected #317

Closed LIghtBallWanted closed 3 years ago

LIghtBallWanted commented 4 years ago
               os:   Windows 10 64 bit

library version: pynput 1.7.1

I wish to make some simple hotkey toolkits for playing a game (dark souls III to be specific). I tried some codes with a listener as the following :

self._keyboardController.press('w') time.sleep(6) self._keyboardController.release('w')

However, it does not work exactly the same as pressing the 'w' key in the real keyboard. When a key is pressed for several seconds, only one character shows. Take the code above for example, only one 'w' instead of a sequence of 'w' shows on the screen.

Besides, it works all the same in chrome, text editor and other software. The press function can be used even without release function, since it produces only one character each time.

moses-palmer commented 3 years ago

Thank you for your report.

Yes, this is an issue that has been reported before. The problem appears to be that although pynput generates keyboard events, the global keyboard state is not updated accordingly, and the operating system does not consider the button to be pressed.

moses-palmer commented 3 years ago

I have updated the documentation to mention this limitation for windows.