pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.63k stars 836 forks source link

Multiple remap #3816

Open Falven opened 4 months ago

Falven commented 4 months ago

I'm trying to set up Karabiner-elements to remap both Cmd + Left Arrow to Home and Cmd to Ctrl simultaneously. Ie. if I press Cmd + Left Arrow it should send Home, but if I press, for example Cmd + D it should send Ctrl + D; or if I simply press Cmd it should send Ctrl. The following are the rules in my karabiner.json:

[
    {
        "description": "(Remote Desktop) Cmd + Left Arrow to Home",
        "manipulators": [
            {
                "conditions": [
                    {
                        "bundle_identifiers": [
                            "com\\.microsoft\\.rdc\\.mac",
                            "com\\.ericom\\.blazeclient"
                        ],
                        "type": "frontmost_application_if"
                    }
                ],
                "type": "basic",
                "from": {
                    "key_code": "left_arrow",
                    "modifiers": {
                        "mandatory": [
                            "left_command"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "home"
                    }
                ]
            }
        ]
    },
    {
        "description": "(Remote Desktop) Cmd to Ctrl for other keys",
        "manipulators": [
            {
                "conditions": [
                    {
                        "bundle_identifiers": [
                            "com\\.microsoft\\.rdc\\.mac",
                            "com\\.ericom\\.blazeclient"
                        ],
                        "type": "frontmost_application_if"
                    }
                ],
                "type": "basic",
                "from": {
                    "key_code": "left_command",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "left_control"
                    }
                ]
            }
        ]
    }
]

I was thinking, in my rules, that the first manipulator would be matched on Cmd + Left Arrow but then not matched on any other Cmd + * key press, leading the second manipulator to be matched for those. But currently, it seems only the second is matched when using Cmd + Left Arrow for some reason.

Falven commented 4 months ago

Essentially there's no easy way I found after looking all around the internet for a few days. The way I ended up doing this is by binding every single combination I need. CMD+Whatever to CTRL+Whatever