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.73k stars 836 forks source link

Keybindings aren't working when caps lock is turned on. #2523

Open riceset opened 3 years ago

riceset commented 3 years ago

Hi there! I just noticed that when caps lock is turned on, Karabiner stops working, and when I turn it off it starts working again. I use the capslock key to switch my keyboard language (japanese-english) so I need this key.

MacOS big sur 11.0.1(20B29) karabiner (lastest update)

GeoJunkie commented 3 years ago

This is happening for me, too. I have my Application key bound as a Hyperkey, but when Caps Lock is on it reverts to being an Application key again

I also have the exact same versions as @riceset (Karabiner is on 13.1.0 as of right now).

GeoJunkie commented 3 years ago

I did some more testing and it only seems to effect modifier keys. Could this be from something that changed in Big Sur?

Here's the pertinent part of my karabiner.json file:

{
                "rules": [
                    {
                        "description": "Modify caps_lock",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "mandatory": [
                                            "shift"
                                        ]
                                    }
                                },
                                "to": {
                                    "key_code": "delete_forward"
                                },
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "mandatory": [
                                            "shift",
                                            "control",
                                            "option",
                                            "command"
                                        ]
                                    }
                                },
                                "to": {
                                    "key_code": "caps_lock"
                                },
                                "type": "basic"
                            },
                            {
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": {
                                    "key_code": "delete_or_backspace"
                                },
                                "type": "basic"
                            }
                        ]
                    },
                    {
                        "description": "Change application to command+control+option+shift. Keep as application if alone",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "application"
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift",
                                        "modifiers": [
                                            "left_command",
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "application"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },

I have a Colemak keyboard so I've converted caps_lock to delete_or_backspace, shift+caps_lock to delete_forward, and shift+control+option+command+caps_lock to the actual caps_lock itself. My application key is set to a "Hyperkey" as shift+control+option+command.

When I hit Application-Caps Lock, it works as Caps Lock to turn it on. After that, I can't change the Caps Lock back. caps_lock is still delete_or_backspace, shift+caps_lock is still delete_forward, but the application key is no longer modified, and pressing shift+control+option+command+caps_lock is changed to shift+control+option+command+delete_or_backspace.

If I restart Karabiner-Elements (Preferences > Misc > Restart Karabiner-Elements), everything works again, and I can even use application+caps_lock to turn off Caps Lock and it works again. I can turn off Caps Lock, and the application key keeps working until I turn on Caps Lock again.

mushmelty commented 3 years ago

This behavior is not new. I reported it a few years ago, but the behavior persists throughout each update. I personally use the caps lock key as escape, while holding it down causes it to be left control. My actual caps lock functionality is left shift + right shift, which causes the caps lock to light up, and then all the modifiers stop working.

GeoJunkie commented 3 years ago

Interesting @mushmelty . I never saw it before updating to Big Sur. I wonder if there's a restriction that was activated in the Big Sur update that was off by default but maybe on in your installation?

Maybe there's a permission we need to add back...

ssmooncoder commented 3 years ago

I had the same problem.

Try adding caps_lock to your from optional modifiers

mushmelty commented 3 years ago

@ssmooncoder Adding such code to all my modifications did the trick. Took a little while, but it's well worth it to be able to type in all-caps when I really need to get my point across. I've honestly been waiting almost two years to have that functionality restored. Thank you very much 😎

riceset commented 3 years ago

@ssmooncoder @mushmelty I am sorry, I didn't get it. Where should I add it to?

MuhammedZakir commented 3 years ago

@ssmooncoder @mushmelty I am sorry, I didn't get it. Where I should add it to?

In from.modifiers.optional - https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/:

{
    "type": "basic",
    "from": {
        "key_code": "escape",
        "modifiers": {
            "optional": ["caps_lock"]
        }
    },
    "to": [
        {
            "key_code": "tab"
        }
    ]
}

P.S. If you want your modification to work only when caps lock is turned on, put caps_lock in from.modifiers.mandatory instead. See above link for detailed explanation and examples.

MuhammedZakir commented 3 years ago

I don't think this is a bug. caps_lock is a modifier key [1] and so, just like other modifiers (shift, command, option, fn, etc.), you will need to explicitly mention it in from.modifiers if you want your modification to work while caps lock is pressed or turned on.

[1] https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/#list-of-modifiers