21

I'm using a German Keyboard (Lioncast LK20) with OS X 10.11.5. I set the keymap to German and it is displayed correctly in the settings screen. Unfortunately the following two keys are swapped when I type on the keyboard:

< Key (right of SHIFT)
^ Key (left of 1)

Are there any advanced settings to fix this issue?

enter image description here enter image description here

1
  • This maybe utterly stupid but you could try getting a small arduino to swap the keys for you where the keyboard would go through a bare USB port connected to the arduino and thorugh out of another USB port into your computer?
    – Bradman175
    May 30, 2016 at 9:30

6 Answers 6

6
+50

You can use Ukelele to change the keyboard layout so the meaning of those keys are swapped:

http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ukelele

Note the program is called "Ukelele", not "Ukulele".

3
  • 1
    This will swap the keys on any other keyboard you have connected. May 7, 2019 at 10:44
  • As @Stefano Palazzo noted, this creates a new problem. I believe this should be selected as the correct answer: apple.stackexchange.com/a/359559/160407
    – ssssaaaa
    Aug 31 at 6:06
  • Depends on the Mac you have - if you have a non-laptop Mac such as an iMac, Mac Mini or Mac Pro - then it is very unusual to have more than one keyboard.
    – jksoegaard
    Aug 31 at 6:29
17

This is because your keyboard isn't set as ISO standard. This happens sometimes.

To change it to the right type:

  1. Open System Preferences > Keyboard, select the Keyboard tab and then 'Change Keyboard Type...'

    This opens the Keyboard Setup Assistant.

  2. Follow the prompt 'Press the key to the right of the shift key on the left side.'

    It should now have detected and selected 'ISO' as your standard. If not select it and click 'OK'. 'ISO' is generally used for European keyboards.

If this doesn't solve it, you can try manually resetting the settings file:

  1. Delete /Library/Preferences/com.apple.keyboardtype.plist
  2. Restart
  3. When the keyboard assistent pops up. press the key like it says and select ISO (European)

Note: The problem with fixing this with Ukelele as the selected answer, is that it will swap the keys the other way around on your internal keyboard.

6
  • I don't think your fix would have worked for the original poster, as his Input Source preference pane shows he already had ISO as the recognized type. For you I would expect this pane to have shown a layout without the key next to the left shift, which means it was missrecognized as ANSI. Aug 21, 2019 at 15:31
  • Hard to say, but it was the same for me; the input sources preference pane looked correct but the keys were swapped. Aug 22, 2019 at 10:23
  • 3
    I had the exact same problem as OP with the same keyboard, but on OSX 10.15.2. After reboot keyboard assistent solved the problem! Thank you!
    – illnr
    Jan 30, 2020 at 8:11
  • The problem appeared for me the first time under Catalina 10.15... Strange is that I had to apply this "correction" several times as after a while, one day, or early morning, the keyboards suddenly behaved different... very very strange Jun 24, 2021 at 23:25
  • For me, deleting this file and Logout/Login was enough (external Microsoft Sculpt keyboard)
    – oarfish
    Mar 18 at 11:58
8

You can use Karabiner to swap the keys using the following private.xml.

<?xml version="1.0"?>
<root>
  <item>
    <name>Swap Keys</name>
    <identifier>private.swapkeys</identifier>
    <autogen>__KeyToKey__ KeyCode::one, KeyCode::two</autogen>
    <autogen>__KeyToKey__ KeyCode::two, KeyCode::one</autogen>
  </item>
</root>

You'll need to find the KeyCode for the keys you want to swap as I don't have a German keyboard to check. You can use EventViewer accessible from Karabiner → Misc to find the KeyCodes. Replace one with one KeyCode and two with the other KeyCode in the above private.xml.

1
  • 3
    Karabiner-Elements is the newer and better Karabiner. I also like the new JSON configs more than Karabiner's XML. Aug 21, 2019 at 15:37
3

I bizarrely had this problem after buying a new mouse (SteelSeries Rival 3), which is plugged into a USB-C monitor (with a keyboard plugged in to the monitor as well), and the monitor has a single USB-C cable going to the MacBook. I could also imagine this being a problem when using USB dongles.

The fix that worked for me:

  1. In the terminal, remove the keyboardtype file sudo rm /Library/Preferences/com.apple.keyboardtype.plist, from the accepted answer.
  2. Remove both keyboard and mouse from the USB ports on the monitor/USB hub.
  3. Reboot the computer.
  4. After logging in, plug in the keyboard. Complete the identification. Your keys should work as intended.
  5. Plug in the mouse to the monitor. Close the new identification box that opened up. Everything should work.
1
  • Wow, this is the same setup (except with a Logitech mouse) that I currently have with this issue. Why this would swap keys is beyond me...
    – chrisma
    Aug 15 at 13:52
1

Open System Preferences -> Keyboard -> Tab Keyboard -> Change Keyboard Type... -> Keyboard Setup Assistant -> Press the key to the right of the shift key on the left side.

If not available use procedure of Stefano

0

Deleting /Library/Preferences/com.apple.keyboardtype.plist and relying on the keyboard type detection wizard repeatedly did not work for me for my external german keyboard (having also an internal german keyboard).

But editing the file /Library/Preferences/com.apple.keyboardtype.plist manually worked!

This is what I did:

sudo plutil -convert xml1 /Library/Preferences/com.apple.keyboardtype.plist

Edit file /Library/Preferences/com.apple.keyboardtype.plist and change type 43 to 41 (or the other way round, depending on what you have) for all the keyboards (or just for the relevant one, but I was not able to figure out which one to change so I changed them all).

sudo plutil -convert binary1 /Library/Preferences/com.apple.keyboardtype.plist

Reboot. Now the < and the ^ keys should be swapped.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .