Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added keyboard layout adjustment #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kennyhml
Copy link

Hey Ben!

I recently had to switch from using pyautogui to pydirectinput for one of my projects.

When trying to press Z, I realized the actual outcome was Y, because your scancodes are QWERTY based, which means on a QWERTZ based keyboard, Y comes out as Z and vice versa, even worse for AZERTY layouts!

So, as a quick fix for this (rather pesky) issue, we can simply use the MapVirtualKey as you already have been for the arrow keys, to make this slightly less code, we can simply iterate over all the keycodes and map them to their character.

for c in range(32, 92):
    KEYBOARD_MAPPING[chr(c).lower()] = MapVirtualKey(c, MAPVK_VK_TO_VSC)

Since the function comes from ctypes too, theres no need for further imports and changes.

Hope this helps and is lightweight enough for you to simply accept it.

Thanks for your great work and videos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant