snippets/old_snippets/remap-section-sign-to-backslash-mac-osx.en.md

64 lines
2 KiB
Markdown

---
date: 2022-06-05T10:26:08.000Z
title: remap §/± to `/~ on max osx
draft: false
snippet_types:
- mac
- osx
seo_description: How to remap (§) section sign to (`) backslash on mac.
---
Got a new Macbook Pro with the start of my new job and I love it. Except. It did
not come with and english keyboard. Now every time I try to type the backslash (\`)
or tilde (\~) instead I get "§" or "±" 😔. Lucky for me there are a bunch of people
with the same issue.
This base command to remap the key is:
```shell
$ hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x700000064,
"HIDKeyboardModifierMappingDst":0x700000035}]
}'
```
but to make this survive a computer restart things get a little more complicated.
For that you need you need a LaunchDaemon.
/Library/LaunchDaemons/org.custom.backslash-key-remap-fix.plist
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.custom.backslash-key-remap-fix</string>
<key>ProgramArguments</key>
<array>
<string>/Users/travis.shears/projects/scripts/bin/backslash-key-remap-fix.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
```
/Users/travis.shears/projects/scripts/bin/backslash-key-remap-fix.sh
```shell
#/bin/sh -e
hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x700000064,
"HIDKeyboardModifierMappingDst":0x700000035}]
}'
```
## Sources:
* [https://rakhesh.com/mac/using-hidutil-to-map-macos-keyboard-keys/](https://rakhesh.com/mac/using-hidutil-to-map-macos-keyboard-keys/)
* [https://www.grzegorowski.com/how-to-remap-single-mac-keyboard-key](https://www.grzegorowski.com/how-to-remap-single-mac-keyboard-key)
* [https://superuser.com/questions/37042/remapping-of-keys-in-mac-os-x](https://superuser.com/questions/37042/remapping-of-keys-in-mac-os-x)