Karabiner-elements: Complex modification not working

Created on 24 Apr 2019  路  6Comments  路  Source: pqrs-org/Karabiner-Elements

I've started up my computer today and found my two binds don't work

The bind I used to have were:

caps locks -> escape
hold caps lock -> ctrl + cmd + shift + option

Here is my karabiner.json, I haven't knowingly made any change to it, I've tried restoring the karabiner.json from an old gist but still doesn't work

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": false
    },
    "profiles": [
        {
            "complex_modifications": {
                "parameters": {
                    "basic.simultaneous_threshold_milliseconds": 50,
                    "basic.to_delayed_action_delay_milliseconds": 500,
                    "basic.to_if_alone_timeout_milliseconds": 1000,
                    "basic.to_if_held_down_threshold_milliseconds": 500
                },
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change caps_lock to command+control+option+shift.",
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift",
                                        "modifiers": [
                                            "left_command",
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape",
                                        "modifiers": {
                                            "optional": [
                                                "any"
                                            ]
                                        }
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "devices": [
                {
                    "disable_built_in_keyboard_if_exists": false,
                    "fn_function_keys": [],
                    "identifiers": {
                        "is_keyboard": true,
                        "is_pointing_device": false,
                        "product_id": 49277,
                        "vendor_id": 1133
                    },
                    "ignore": true,
                    "manipulate_caps_lock_led": false,
                    "simple_modifications": []
                }
            ],
            "fn_function_keys": [
                {
                    "from": {
                        "key_code": "f1"
                    },
                    "to": {
                        "key_code": "display_brightness_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f2"
                    },
                    "to": {
                        "key_code": "display_brightness_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f3"
                    },
                    "to": {
                        "key_code": "mission_control"
                    }
                },
                {
                    "from": {
                        "key_code": "f4"
                    },
                    "to": {
                        "key_code": "launchpad"
                    }
                },
                {
                    "from": {
                        "key_code": "f5"
                    },
                    "to": {
                        "key_code": "illumination_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f6"
                    },
                    "to": {
                        "key_code": "illumination_increment"
                    }
                },
                {
                    "from": {
                        "key_code": "f7"
                    },
                    "to": {
                        "key_code": "rewind"
                    }
                },
                {
                    "from": {
                        "key_code": "f8"
                    },
                    "to": {
                        "key_code": "play_or_pause"
                    }
                },
                {
                    "from": {
                        "key_code": "f9"
                    },
                    "to": {
                        "key_code": "fastforward"
                    }
                },
                {
                    "from": {
                        "key_code": "f10"
                    },
                    "to": {
                        "key_code": "mute"
                    }
                },
                {
                    "from": {
                        "key_code": "f11"
                    },
                    "to": {
                        "key_code": "volume_decrement"
                    }
                },
                {
                    "from": {
                        "key_code": "f12"
                    },
                    "to": {
                        "key_code": "volume_increment"
                    }
                }
            ],
            "name": "Default profile",
            "selected": true,
            "simple_modifications": [
                {
                    "from": {
                        "key_code": "right_command"
                    },
                    "to": {
                        "key_code": "left_control"
                    }
                }
            ],
            "virtual_hid_keyboard": {
                "caps_lock_delay_milliseconds": 0,
                "country_code": 0,
                "keyboard_type": "ansi"
            }
        }
    ]
}

Most helpful comment

Here's my entire caps lock section:

{
    "manipulators": [
        {
            "description": "Change caps_lock to command+control+option+shift.",
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [ "any" ]
                }
            },
            "to": [
                {
                    "key_code": "left_shift",
                    "modifiers": [
                        "left_command",
                        "left_control",
                        "left_option"
                    ]
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "escape"
                }
            ],
            "type": "basic"
        }
    ]
},

I think to_if_alone is inherently modifier-less.

All 6 comments

I think I'm in the same boat here. I noticed in the Log section of the preferences at startup it's got some errors about my json that used to work. I have a caps lock to escape mapping and a hold caps lock to option mapping.

[2019-04-24 12:30:39.114] [error] [grabber] karabiner.json error: `to_if_alone` entry error: `modifiers` error: json must be array or string, but is `{"optional":["any"]}`
[2019-04-24 12:30:39.114] [error] [grabber] karabiner.json error: `to` entry error: `modifiers` error: json must be array or string, but is `{"optional":["any"]}`
[2019-04-24 12:30:39.114] [error] [grabber] karabiner.json error: `to` entry error: `modifiers` error: json must be array or string, but is `{"optional":["any"]}`
[2019-04-24 12:30:39.114] [error] [grabber] karabiner.json error: `to` entry error: `modifiers` error: json must be array or string, but is `{"optional":["any"]}`
[2019-04-24 12:30:39.114] [error] [grabber] karabiner.json error: `to` entry error: `modifiers` error: json must be array or string, but is `{"optional":["any"]}`

I had the same problem and just removed the modifiers property entirely. Everything works fine and there are no errors in the Log tab:

"to_if_alone": [
  {
    "key_code": "escape"
  }
],

I had the same problem and just removed the modifiers property entirely. Everything works fine and there are no errors in the Log tab:

"to_if_alone": [
  {
    "key_code": "escape"
  }
],

Removing the modifiers property makes it so I can't hold other modifiers with the key definition.

For instance, I have caps lock remapped control but to escape if left alone. If I hold any other modifier in addition to caps lock, I get caps lock instead of control. I assume this was the intention behind defining modifiers as "optional: any".

Here's my entire caps lock section:

{
    "manipulators": [
        {
            "description": "Change caps_lock to command+control+option+shift.",
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [ "any" ]
                }
            },
            "to": [
                {
                    "key_code": "left_shift",
                    "modifiers": [
                        "left_command",
                        "left_control",
                        "left_option"
                    ]
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "escape"
                }
            ],
            "type": "basic"
        }
    ]
},

I think to_if_alone is inherently modifier-less.

@bbrown I think this works for you because you're essentially remapping caps lock to all the modifiers.

In my configuration:

"manipulators": [
    {
        "description": "Change caps to ctrl/esc",
        "from": {
            "key_code": "caps_lock"
        },
        "to": [
            {
                "key_code": "left_control"
            }
        ],
        "to_if_alone": [
            {
                "key_code": "escape"
            }
        ],
        "type": "basic"
    }
]

Pressing Caps+A will send Ctrl+A as expected, however pressing Caps+Cmd+A will send Caps Lock + A, which is not expected (it should send Ctrl+Cmd+A).

I'm not sure if this is a new bug, or if this was something that started happening after removing "modifiers: optional" from my config.

Never mind, I was able to fix this by simply moving the modifiers: optional:any block to the "from" rule, which makes a lot more sense.

yep can confirm modifiers: optional : any where any is a string works

Was this page helpful?
0 / 5 - 0 ratings