keyboard icon indicating copy to clipboard operation
keyboard copied to clipboard

user32.keybd_event trigger a release for modifiers, which makes send function glitched

Open SunOfJudge opened this issue 1 year ago • 1 comments

It seems that on windows platform _os_keyboard eventually calls user32.keybd_event. However, it makes the pressed modifiers to release for some reason. Note that modifiers and non-modifiers are different and this affect only modifiers. You can replicate it through the following code:

import keyboard, time
while True:
    time.sleep(2)
    keyboard._os_keyboard.press(keyboard.key_to_scan_codes("right")[0])

Hold shift key and run the code, you will find that the text cursor moves but the text is not selected, which is a proof that the shift key is released for a sudden. This can be patched by modifying send function.

SunOfJudge avatar Apr 04 '23 14:04 SunOfJudge

I think because right is an extended key (0xE05D), it is misread. maybe this can fix your problem: https://github.com/boppreh/keyboard/pull/606

girvile avatar May 25 '23 14:05 girvile