Skip to content

Instantly share code, notes, and snippets.

@Dominent
Created February 20, 2017 21:06
Show Gist options
  • Save Dominent/814a3003c99c039bda3ef81559c0f0a9 to your computer and use it in GitHub Desktop.
Save Dominent/814a3003c99c039bda3ef81559c0f0a9 to your computer and use it in GitHub Desktop.
<#
Author: Dominent
Usage: Switches CAPS_LOCK with LEFT_CTRL
Date: 02/20/2017
Remarks: Tested on Windows 10 Build 14986
https://msdn.microsoft.com/windows/hardware/drivers/hid/keyboard-and-mouse-class-drivers
https://rayli.net/blog/life/remap-keys-map-caps-lock-to-control-button/
http://smallvoid.com/article/winnt-scancode-map.html
#>
[string]$REGISTRY_PATH = 'HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout';
[string]$PROPERTY_NAME = 'Scancode Map';
<#
#CAPS_LOCK -> LEFT_CTRL
$byteMap = [Byte[]] (
0x00, 0x00, 0x00, 0x00, #Header: Version. Set to all zeroes.
0x00, 0x00, 0x00, 0x00, #Header: Flags. Set to all zeroes.
0x02, 0x00, 0x00, 0x00, #Two entries in the map (including null entry).
0x1D, 0x00, 0x3A, 0x00, #LEFT_CTRL -> CAPS_LOCK
0x00, 0x00, 0x00, 0x00); #Null terminator
#>
#CAPS_LOCK -> LEFT_CTRL, LEFT_CTRL -> CAPS_LOCK
$byteMap = [Byte[]] (
0x00, 0x00, 0x00, 0x00, #Header: Version. Set to all zeroes.
0x00, 0x00, 0x00, 0x00, #Header: Flags. Set to all zeroes.
0x03, 0x00, 0x00, 0x00, #Three entries in the map (including null entry).
0x1D, 0x00, 0x3A, 0x00, #LEFT_CTRL -> CAPS_LOCK
0x3A, 0x00, 0x1D, 0x00, #CAPS_LOCK -> LEFT_CTRL
0x00, 0x00, 0x00, 0x00); #Null terminator
New-ItemProperty `
-Path $REGISTRY_PATH `
-Name $PROPERTY_NAME `
-PropertyType Binary `
-Value $byteMap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment