Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active October 21, 2021 02:38
Show Gist options
  • Save JohnL4/be609c3570465db87f5a322f2dccf997 to your computer and use it in GitHub Desktop.
Save JohnL4/be609c3570465db87f5a322f2dccf997 to your computer and use it in GitHub Desktop.
PowerShell script to permanently swap caps-lock and control by registry hack
<# Writes a registry entry to swap caps lock and left control permanently. This affects all users and the login screen, and doesn't
require any other software to run after this (e.g., PowerToys). Requires a reboot after this script is run to take effect.
Courtesy of https://www.mavjs.org/post/swap-ctrl-and-capslock-on-windows/
#>
$hexified = "00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00".Split(",") | % { "0x$_"};
$kbLayout = 'HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment