# Script found at https://superuser.com/a/997448 # Swap details found at https://www.mavjs.org/post/swap-ctrl-and-capslock-on-windows # Improvement provided by Davido264 in comment below $hexified = "00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00".Split(',') | % { "0x$_"}; $kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout'; $scancodeMap = Get-ItemProperty -Path $kbLayout -Name "Scancode Map" -ErrorAction Ignore if ( -not $scancodeMap ) { New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified); } else { Set-ItemProperty -LiteralPath $kbLayout -Name "Scancode Map" -Value ([byte[]]$hexified); }