DEV Community

Lawrence Chen
Lawrence Chen

Posted on • Edited on

Remap Caps Lock to Escape or Control

Emacs

Caps Lock to Control

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x7000000E0}]}'
Enter fullscreen mode Exit fullscreen mode

Vim

Caps Lock to Escape

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}'
Enter fullscreen mode Exit fullscreen mode

This seems to not affect external keyboards in my setup. If you know a fix, please drop a comment!

Reset

Caps Lock to Caps Lock

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000039}]}'
Enter fullscreen mode Exit fullscreen mode

Learn More (Remap Other Keys)

https://developer.apple.com/library/archive/technotes/tn2450/_index.html

Credits: https://superuser.com/a/1405422

Top comments (0)