pqrs-org / Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
https://pqrs.org/osx/karabiner/
The Unlicense
3.82k stars 309 forks source link

How to do non-recursive mapping? #865

Closed trusktr closed 6 years ago

trusktr commented 6 years ago

In my Complex Modifications tab I've mapped caps_lock to left_control. Then in my Simple Modifications tab I've mapped right_option to caps_lock.

Expected: I want right_option to toggle capslock on/off

Actual: right_option presses left_control because right_option -> caps_lock -> left_control (the mapping is recursive).

How do I make it non-recursive?

trusktr commented 6 years ago

ALRIGHT, FIGURED IT OUT HALF WAY (AS YOU CAN TELL): IF I PUT MAPPING OF RIGHT_OPTION INTO COMPLEX MODIFIERS, THEN IT SUCCEEDS TURNING ON CAPSLOCK, BUT IT DOES NOT TURN OFF.

HOW CAN I MAKE IT TOGGLE, NOT ONLY TURN ON??? 🤔

trusktr commented 6 years ago

Oh, okay, I quit Karabiner app to make it turn off. 😆

trusktr commented 6 years ago

Alright, I read the documentation more, and it says to put manipulators in order so that the first match is executed and subsequent ones are ignored. However, this still isn't working. My config looks like the following. I'm trying to make Capslock be Control or Command, and Right Option to be Casplock. But what happens is that Right Option turns Capslock on, but can never turn it off.

Any ideas?

{
    "title": "Capslock as Control or Command, Right Option as Capslock",
    "rules": [
        {
            "description": "Capslock as Control in Terminal or similar apps, Right Option as Capslock",
            "manipulators": [
                {
                    "type": "basic",
                    "from": { "key_code": "right_option" },
                    "to": [ { "key_code": "caps_lock" } ]
                },
                {
                    "type": "basic",
                    "conditions": [
                        {
                            "type": "frontmost_application_if",
                            "bundle_identifiers": [
                                "^com\\.apple\\.Terminal$",
                                "^com\\.googlecode\\.iterm2$",
                                "^co\\.zeit\\.hyperterm$",
                                "^co\\.zeit\\.hyper$",
                                "^io\\.alacritty$",
                                "^net\\.kovidgoyal\\.kitty$",
                                "^com\\.github\\.atom$"
                            ]
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": { "optional": [ "any" ] }
                    },
                    "to": [ { "key_code": "left_control" } ]
                }
            ]
        },
        {
            "description": "Capslock as Command in non-Terminal or similar apps, Right Option as Capslock",
            "manipulators": [
                {
                    "type": "basic",
                    "from": { "key_code": "right_option" },
                    "to": [ { "key_code": "caps_lock" } ]
                },
                {
                    "type": "basic",
                    "conditions": [
                        {
                            "type": "frontmost_application_unless",
                            "bundle_identifiers": [
                                "^com\\.apple\\.Terminal$",
                                "^com\\.googlecode\\.iterm2$",
                                "^co\\.zeit\\.hyperterm$",
                                "^co\\.zeit\\.hyper$",
                                "^io\\.alacritty$",
                                "^net\\.kovidgoyal\\.kitty$",
                                "^com\\.github\\.atom$"
                            ]
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": { "optional": [ "any" ] }
                    },
                    "to": [ { "key_code": "left_command" } ]
                }
            ]
        }
    ]
}
trusktr commented 6 years ago

I thought I would try to_if_alone so that I can just press capslock to turn on capslock, otherwise act as Control or Command with other keys, but it doesn't seem to work, capslock doesn't turn on. That config looks like this:

{
    "title": "Capslock as Control or Command, Right Option as Capslock",
    "rules": [
        {
            "description": "Capslock as Control in Terminal or similar apps, Right Option as Capslock",
            "manipulators": [
                {
                    "type": "basic",
                    "conditions": [
                        {
                            "type": "frontmost_application_if",
                            "bundle_identifiers": [
                                "^com\\.apple\\.Terminal$",
                                "^com\\.googlecode\\.iterm2$",
                                "^co\\.zeit\\.hyperterm$",
                                "^co\\.zeit\\.hyper$",
                                "^io\\.alacritty$",
                                "^net\\.kovidgoyal\\.kitty$",
                                "^com\\.github\\.atom$"
                            ]
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": { "optional": [ "any" ] }
                    },
                    "to": [ { "key_code": "left_control" } ],
                    "to_if_alone": [ { "key_code": "caps_lock" } ]
                }
            ]
        },
        {
            "description": "Capslock as Command in non-Terminal or similar apps, Right Option as Capslock",
            "manipulators": [
                {
                    "type": "basic",
                    "conditions": [
                        {
                            "type": "frontmost_application_unless",
                            "bundle_identifiers": [
                                "^com\\.apple\\.Terminal$",
                                "^com\\.googlecode\\.iterm2$",
                                "^co\\.zeit\\.hyperterm$",
                                "^co\\.zeit\\.hyper$",
                                "^io\\.alacritty$",
                                "^net\\.kovidgoyal\\.kitty$",
                                "^com\\.github\\.atom$"
                            ]
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": { "optional": [ "any" ] }
                    },
                    "to": [ { "key_code": "left_command" } ],
                    "to_if_alone": [ { "key_code": "caps_lock" } ]
                }
            ]
        }
    ]
}

When this config is in effect, the events look like this:

screen shot 2018-05-27 at 12 29 54 am

But it does not turn on capslock, and everything is still lowercase.

trusktr commented 6 years ago

Perhaps am I having a bug related to https://github.com/tekezo/Karabiner-Elements/issues/467?

trusktr commented 6 years ago

Oops, this this is the wrong repo, moving there.