27

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

multiholle
  • 323
  • 1
  • 3
  • 7
  • 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 '16 at 09:30

9 Answers9

19

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.

ssssaaaa
  • 395
  • 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. – Tom Gewecke Aug 21 '19 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. – Stefano Palazzo Aug 22 '19 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 '20 at 08: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 – Canelo Digital Jun 24 '21 at 23:25
  • For me, deleting this file and Logout/Login was enough (external Microsoft Sculpt keyboard) – oarfish Mar 18 '22 at 11:58
  • Yeah, I believe this should be the correct answer. @TomGewecke I don't think you're right. My Input Source also was listed as ISO when I plugged my keyboard into my new mac, but I had the same problem. Resetting the standard with Keyboard assistant solved it. – ssssaaaa Aug 31 '22 at 06:11
  • @TomGewecke after some time the problem reappeared, so seems you're right MacOS for some reason misidentifes the keyboard, though it's shown as corrected identified as ISO. – ssssaaaa Dec 28 '22 at 13:02
  • Problem for me was my USB-hub which made all devices being identified as the same keyboard. – Gustav May 23 '23 at 09:28
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!

grg
  • 201,078
7

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".

Thinkr
  • 3,357
jksoegaard
  • 77,783
  • 1
    This will swap the keys on any other keyboard you have connected. – Stefano Palazzo May 07 '19 at 10:44
  • As @Stefano Palazzo noted, this creates a new problem. I believe this should be selected as the correct answer: https://apple.stackexchange.com/a/359559/160407 – ssssaaaa Aug 31 '22 at 06: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 '22 at 06: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... – Fran Marzoa Dec 16 '22 at 10:52
7

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.

  • 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: https://apple.stackexchange.com/a/240053/160407

    – ssssaaaa Dec 31 '22 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 '22 at 22:35
  • 1
    YOU THE MAN G Thank you this worked Ich küss dein Auge – DavidsKanal Jan 11 '23 at 09:32
  • sounds like the long term solution. Thanks for sharing! – kluka Jun 02 '23 at 12:29
  • 1
    You can temporarily open karabiner elements and go to devices, it will show you the device ids, which you can use to figure out which entries should be modified in the XML. – Alexis Mar 16 '24 at 23:26
  • After I already accepted my faith that I won't be using my Epomaker Bluetooth keyboard wirelessly for the rest of my life, this did the trick. Thank you! – fsimonjetz Mar 19 '24 at 15:42
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.
Sander
  • 141
  • 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 '22 at 13:52
0

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.

agarza
  • 2,274
User Rebo
  • 109
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.

epeios
  • 1
0

Finally, I Installed Karabine and it worked like a charm. After installation, you have to add some permissions described here:

https://github.com/pqrs-org/Karabiner-Elements/issues/3011#issuecomment-1163033840

Finally, I opened Karabine, then I toggled on the button "treat as a built-in keyboard", that is enough and you don't need to map any key

Karabine config image

-1

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.

agarza
  • 2,274
MCK
  • 1