macOS - External Keyboard keys are swapped (solved)
Sometimes macOS could be painful..
Published:
1 minute read
Issue
My case:
<
and ^
keys are swapped
<
Key (right of SHIFT)^
Key (left of 1)
This is because macOS set the wrong keyboard type (ISO, ANSI, JIS, ..) even if the config wizard shows the right result.
On QMK based keyboards:
- KC_NUBS
- ISO:
< >
- ANSI: Non-US
\
and|
- ISO:
- KC_GRV
- ISO:
^ °
- ANSI:
~ ´
- ISO:
macOS default settings
System Settings --> Keyboard --> Change Keyboard Type --> go through the Wizard --> Done.
But for me and a lot of others with external keyboards not from Apple this won't work. In the past I fixed this issue with Karabiner-Elements , but this is more like a workaround as a proper fix. A further option would be to remap the keyboard key's on QMK or VIA Keyboards, but this is crazy and won't work in combination with other operating systems.
Easy Fix
Enforce macOS to indentify the keyboard type without any previous knowledge:
sudo rm /Library/Preferences/com.apple.keyboardtype.plist
- Remove both keyboard and mouse from the USB ports on the monitor/USB hub.
- Reboot
If still not working
sudo plutil -convert xml1 /Library/Preferences/com.apple.keyboardtype.plist
- text edit e.g.
sudo nvim /Library/Preferences/com.apple.keyboardtype.plist
- change type 43 to 41 (or 43 if there is already a 41 - but change back after reboot.)
- change all - may after restart new ones getting in
sudo plutil -convert binary1 /Library/Preferences/com.apple.keyboardtype.plist
(Converting back to binary is optional - reboot will also fix this.)- Reboot - with unplugged keyboard.
- Repeat until the macOS keyboard detection tool doesn't detect new keyboards after login - .plist get's extended each time.
In my case this was the result after a few restarts and changes:
<?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>keyboardtype</key>
<dict>
<key>1031-4176-0</key>
<integer>41</integer>
<key>5-41219-0</key>
<integer>41</integer>
<key>50504-1133-0</key>
<integer>41</integer>
<key>6-41219-0</key>
<integer>41</integer>
</dict>
</dict>
</plist>