I have a program that is basically just waiting for a keypress and then passing the scan code through to keyboard.send() (running on Windows with a standard US keyboard layout), but it's outputting incorrect characters. For example, pressing the semicolon key (;) produces scan code 39, but keyboard.send(39) outputs a grave (`) character.
The core issue seems to be that the calls to MapVirtualKeyExW() (in _setup_name_tables()) are producing incorrect mappings. In _setup_name_tables(), the semicolon (name == ';') is being mapped to these entries: [(26, 186, ...), (39, 192, ...)]. I think the correct scan code for semicolon is 39, and the correct vk is 186, so the scancode->vk mapping (which is output from MapVirtualKeyExW) is incorrect - it seems to be mixed up with the scan code and vk for the grave key (26 and 192, respectively). Any idea why it's outputting an incorrect mapping, or how to fix it?
I have a program that is basically just waiting for a keypress and then passing the scan code through to keyboard.send() (running on Windows with a standard US keyboard layout), but it's outputting incorrect characters. For example, pressing the semicolon key (;) produces scan code 39, but keyboard.send(39) outputs a grave (`) character.
The core issue seems to be that the calls to MapVirtualKeyExW() (in _setup_name_tables()) are producing incorrect mappings. In _setup_name_tables(), the semicolon (name == ';') is being mapped to these entries: [(26, 186, ...), (39, 192, ...)]. I think the correct scan code for semicolon is 39, and the correct vk is 186, so the scancode->vk mapping (which is output from MapVirtualKeyExW) is incorrect - it seems to be mixed up with the scan code and vk for the grave key (26 and 192, respectively). Any idea why it's outputting an incorrect mapping, or how to fix it?