keyboard
keyboard copied to clipboard
user32.keybd_event trigger a release for modifiers, which makes send function glitched
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.
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