26

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

8 Answers 8

7
+50

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

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

4
  • 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, 2022 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, 2022 at 6:29
  • @ssssaaaa that answer doesn't work for many people, me included. My keyboard is detected as ISO, but then the US layout is as if it was ANSI instead. I have tried trashing that plist file to no avail. I also tried editing it, but if I fix it for the Spanish layout, it breaks for the US layout and vice versa, and I need to use both layouts so I'm screwed and I'll have to learn to live with the swapped keys in one of them I guess... Dec 16, 2022 at 10:52
18

Update: This appears to be an MacOS issue where the OS shows that that keyboard is listed as (fx. in my case) ISO-type, but in reality MacOS handles it as a ANSI-type (or vice versa with other standard keyboard-types).

You can use the guide below to try and set it correctly in Macos again, however it seems like the issue reappears after some time for a lot of users (see comments to this answer).

If the issue reappears please try using a keyboard-editor like the ones listed in the other answers.

This can be 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.

8
  • 1
    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, 2022 at 11:58
10

You can use Karabiner Elements to swap the keys using Karabiner Eventviewer to find the keycodes of the keys:

  1. Make sure the keyboard you experience the issue with is plugged in.

  2. Install Karabiner Elements. Karabiner Eventviewer will be installed with it.

  3. Open Karabiner Eventviewer. Without pressing any other keys, press the two keys you want to swap. The keys ‘key name’ is now shown in the ‘Name’ column. Remember these names or keep the Eventviwer open, to reference again.

    Note: If you're unsure if you have found the correct keys, click the ‘clear the result’ button and then press each of the two keys you want to swap again. Now their ‘key names’ should be at the top of the list like on the screenshot below.

    Screenshot of Karabiner Eventviewer showing action 3 having been done

  4. Open Karabiner Elements and select the keyboard you have the issue with as your ‘Target device:’ in the dropdown.

  5. Add two new items to the list and find each ‘key name’ from Karabiner Eventviewer in ‘From key’ column, for each of the new items. Now add the opposite key in the ‘To key’ column for each item (see screenshot for reference).

    Screenshot of Karabiner Elements showing action 4 and 5 having been done

  6. You have now swapped the keys!

0
4

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, 2022 at 13:52
3

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 (Converting back to binary is not necessary, empirically.)

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

Update 2023-08-06: This issue is still present with macOS Ventura 13.5. Pressing the "other" key in "Change Keyboard type ..." does not fix this, but the steps mentioned above do. Setting both keyboards to type 41 fixed the swapped keys for me. But the real cause of this swap is still a mystery. Now the key behaviour in applications is correct, but the keys are swapped in the the "Keyboard Viewer". When pressing the keys the "other" key gets hilted in the Keyboard Viewer. Before applying the fix, then the keys were swapped for applications, the correct keys would hilite in Keyboard Viewer. So the fix above fixes the problem on the wrong level.

4
  • I tried your solution, but it didn't work. All the keyboards were type 40, except for one which was type 43 (so it seemed to be the one). I first changed it to 40 like the others and restarted, which didn't change anything. Then I tried changing it to 41 like you and restarted, which swapped the issues, so the keyboard with the issue worked as expected, but all the others now had the keys swapped. I've now changed it back to all being type 40 and have swapped the keys on the 1 problematic keyboard with Karabiner Elements as per this answer: apple.stackexchange.com/a/240053/160407
    – ssssaaaa
    Dec 31, 2022 at 22:29
  • I'm currently using Mojave for anybody experiencing the same. I'm hoping Apple has fixed this in later MacOS versions.
    – ssssaaaa
    Dec 31, 2022 at 22:35
  • 1
    YOU THE MAN G Thank you this worked Ich küss dein Auge Jan 11 at 9:32
  • sounds like the long term solution. Thanks for sharing!
    – kluka
    Jun 2 at 12:29
1

Open System Preferences > Keyboard > Keyboard tab > Change Keyboard Type... > Keyboard Setup Assistant, then press the key to the right of the Shift key on the left side.

If not available use the procedure of Stefano.

0

Very easy fix I used to solve this: (disclaimer: I don't know what I'm doing.)

When Apple tries to understand your Keyboard by having you click the button next to shift ('<'), I just clicked '^' instead. It proposed ISO (european) then for me, that fixed it.

0

Had the same issue. The easiest and fastest way to change this is just to press the other key! It's so simple!

Just head to System Preferences > Keyboard, then click on Change Keyboard Type...

This opens the Keyboard Setup Assistant.

Now when it asks you to "Press the key to the right of the shift key on the left side." Don't do it! Just press the ^/° key instead. It will set up the keyboard in the correct way.

You must log in to answer this question.

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