boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.76k stars 433 forks source link

Sending a scan code results in the wrong letter being outputted #561

Open Aran-Fey opened 2 years ago

Aran-Fey commented 2 years ago

This issue seems to be related to keyboard layouts. I use colemak, which means pressing the E button on my keyboard actually results in the letter "F".

However, if I use keyboard.press to simulate a key press, it instead results in the letter "E". Here's a small demo:

def on_key_press(event):
    keyboard.press(event.scan_code)

keyboard.on_press_key(18, on_key_press, suppress=True)

Even though the code simply re-sends the same scan code, the E button now produces the letter "E" instead of "F".

OS: Windows 10