Skip to content

Instantly share code, notes, and snippets.

@zbstof
Last active Aug 12, 2021
Embed
What would you like to do?
#!/usr/bin/env bash
# To run at startup:
# sudo defaults write com.apple.loginwindow LoginHook `pwd`/remap.sh
# https://developer.apple.com/library/content/technotes/tn2450/_index.html
CAPS_LOCK="0x700000039"
ESCAPE="0x700000029"
NON_US_BACKSLASH_PLUS_MINUS="0x700000064"
GRAVE_ACCENT_AND_TILDE="0x700000035"
SLASH_PIPE="0x700000031"
ENTER_RETURN="0x700000028"
RIGHT_SHIFT="0x7000000E5" #Do nothing button
FROM="\"HIDKeyboardModifierMappingSrc\""
TO="\"HIDKeyboardModifierMappingDst\""
hidutil property --set "{\"UserKeyMapping\":[
{$FROM: $CAPS_LOCK, $TO: $ESCAPE},
{$FROM: $ESCAPE, $TO: $RIGHT_SHIFT},
{$FROM: $GRAVE_ACCENT_AND_TILDE, $TO: $SLASH_PIPE},
{$FROM: $SLASH_PIPE, $TO: $ENTER_RETURN},
{$FROM: $NON_US_BACKSLASH_PLUS_MINUS, $TO: $GRAVE_ACCENT_AND_TILDE}
]}"
@rchougule
Copy link

rchougule commented Oct 12, 2020

Do you know how can i remap the fn key on my external keyboard? Karabiner doesn't detect my fn keystrokes as well.

@zbstof
Copy link
Author

zbstof commented Nov 21, 2020

Hm, don't know how to help you. The table provided in the technotes doesn't have Fn listed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment