Categories
Uncategorized

Snippets: Map Apple Keyboard Section sign key to back quote ( § to ` )

I’ve been using the Apple keyboards for a while, but when you live in Europe it’s not easy to source the US layout ones that I’m used to.

On macOS there’s an “easy” way to remap the keyboard with just a terminal command:

watch -n1 -x hidutil property -m '{"ProductID":592, "VendorID":1452}' --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064}]}'

What this piece of code does is to change the mapping of the Section key ( § ) to write out the backquote/tilde ( `/ ~ ) key.

The watch -n1 -x part does this every second as sometimes macOS likes to lose the setting, usually when the computer goes to sleep or when the keyboard is unplugged and plugged again.

Please note that on some versions of macOS the watch utility is not installed and needs to be pulled through something like Homebrew or MacPorts.

The above code works with the Apple External keyboard with USB and European layout with Bulgarian letters. It might need a slight adjustment to the hex values for keys for other types of keyboards.

A variation of the command works well for the same type of keyboard on the MacBook Pro itself. You just need to swap the position of the 0x700000035 and 0x700000064 values.

I’ve been thinking of writing a tool to automatically do that for me, but at this point I think it’s more worth it to invest and get a new keyboard with the proper layout 🙂

By Biser Perchinkov

Look, a coder!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s