MacOS – Can’t swap Caps Lock and Esc keys using Seil

caps-lockkeybindingskeyboardmacos

I'm using Seil to remap the Caps Lock button.

Following by instruction I've deactivated Caps Lock by setting it to ‘No Action’ in System Preferences → Keyboard → Modifier Keys.

Then went to Seil's ‘Change the caps lock key’ and set the keycode to 53. Now it works as Esc key and it's functional.

Now I want to make the Esc key work as Caps Lock.

In Karabiner in ‘Change Escape Key’ section I've checked ‘Escape to CapsLock’ checkbox. However it works in completely the wrong way. By pressing Esc button it changes capitalisation, but as well as by pressing Shift+Esc buttons. Also in that mode the Caps Lock button works as a usual button by changing capitalisation.

But if I change it to ‘Shift-Escape to CapsLock’ box then everything works except for one thing, I have to press Shift+Esc to change capitalisation.

So it's not actually a swap between the Esc and Caps Lock buttons.

Am I missing something? How do I fix this problem?

Best Answer

The problem is that you are setting up a recursive key binding.

  1. Seil changes caps lock -> esc
  2. Karabiner changes esc -> caps lock

So in the end when you hit caps lock or esc you will still get caps lock.

caps lock -> esc -> caps lock

When using Seil and Karbiner together you must follow the Input Even Modification Chain to determine the key press outcome (see Example 2 and Plural settings in Karabiner from the link). You have to pay attention to the input event order.

  1. Seil propagates to...
  2. System Preferences > Keyboard > Modifier Keys... which propagates to...
  3. Karabine

In other words, you CAN’T swap just two keys with the Seil & Karabin method you are trying. It will always create a caps lock key press recursion issue.

Rather, you should try to remap both keys with Karbiner only to create a private XML mapping file. This is because Karabiner by itself does not allow you to create recursive event modifications.

I hope this makes logical sense and helps.