Skip to content

Instantly share code, notes, and snippets.

@atsuoishimoto
Last active July 9, 2020 14:47
Show Gist options
  • Save atsuoishimoto/f5268c247fa1a48ff523088a395cf25e to your computer and use it in GitHub Desktop.
Save atsuoishimoto/f5268c247fa1a48ff523088a395cf25e to your computer and use it in GitHub Desktop.
Map capslock to control
import winreg
key = 'System\\CurrentControlSet\\Control\\Keyboard Layout'
scancodemap = (b'\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00'
b'\x00\x00\x1d\x00:\x00\x00\x00\x00\x00')
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key, access=winreg.KEY_WRITE) as h:
winreg.SetValueEx(h, 'Scancode Map', 0, winreg.REG_BINARY, scancodemap)
print('Registry updated. Reboot now.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment