Remapping double-left-SHIFT to CAPS-LOCK in macOS

There seems to be some increasing push against CAPS-LOCK in the mainstream, on all those default keyboards it takes up so much real-estate for so little return.

On my WhiteFox keyboard, I've removed CAPS-LOCK completely, and returned to the old Sun3 keyboard use of Control in that position. I've used the keyboard to remap right-fn/control to toggle the lock, but I was interested to try the same mechanism as iOS/Android have for on-screen keyboards, where double-tapping SHIFT locks it in place (and here you can start the discussion about the differences between SHIFT-LOCK and CAPS-LOCK if you want!)

I couldn't find any mechanism in Kiibohd to do what I wanted; I can set a macro for "[ LS+LS ] => [ CAPSLK ]" which works if I hold the left-SHIFT down long enough for key repeat to kick in, but not for "[ [LS] , [LS] ] => [ CAPSLK ]" – its a valid macro but doesn't seem to trigger.

So I ended up looking at Karabiner-Elements (free software, public domain using https://unlicense.org) (https://pqrs.org/osx/karabiner/index.html) as yet another helper program to run at startup :–) This does allow a “complex modification”, but doesn't help you with the UI to create your own, instead offering a “download examples from our website” process. However, the long and short of it is that this program will read $HOME/.config/karabiner/assets/complex_modifications/ at startup, and any valid json file in there is available for use (not automatically enabled).

So I did the decent thing and copied someone else's script first; “Double tab left_command to become left_control”, (https://pqrs.org/osx/karabiner/complex_modifications/json/double_tap_cmd_to_ctrl.json), and then replaced left_command with left_shift and left_control with caps_lock ... reformatted the file for clarity, restarted Karabiner, enabled the new rule, and enjoyed the results!

{
  "title": "Double left_shift toggles caps_lock",
  "rules": [
    {
      "description": "Double tapping left_shift toggles the caps_lock function. Useful for keyboards without an original caps_lock, or people who are more used to the touchscreen/iOS keyboard paradigm.",
      "manipulators": [
        {
          "conditions": [ { "name": "left_shift pressed", "type": "variable_if", "value": 1 } ],
          "from": { "key_code": "left_shift", "modifiers": { "optional": [ "any" ] } },
          "to": [ { "key_code": "caps_lock" } ],
          "type": "basic"
        },
        {
          "from": { "key_code": "left_shift", "modifiers": { "optional": [ "any" ] } },
          "to": [ { "set_variable": { "name": "left_shift pressed", "value": 1 } }, { "key_code": "left_shift" } ],
          "to_delayed_action": {
            "to_if_canceled": [ { "set_variable": { "name": "left_shift pressed", "value": 0 } } ],
            "to_if_invoked":  [ { "set_variable": { "name": "left_shift pressed", "value": 0 } } ]
          },
          "type": "basic"
        } ]
    } ] }