Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from.optional is not optional, it became required. #4075

Open
XuPengfei-1020 opened this issue Dec 26, 2024 · 5 comments
Open

from.optional is not optional, it became required. #4075

XuPengfei-1020 opened this issue Dec 26, 2024 · 5 comments

Comments

@XuPengfei-1020
Copy link

XuPengfei-1020 commented Dec 26, 2024

Rule From.modifiers must with a optional or it will not work.
OS version: 15.2 (24C101)
karabiner version: 15.3.0

Test rule:

{
    "description": "ctrl + c -> cmd + c",
    "manipulators": [
        {
            "from": {
                "key_code": "c",
                "modifiers": {
                    "mandatory": ["left_control"],
                    // "optional": ["any"] // If I comment this line, this rule will not work.
                }
            },
            "to": [
                {
                    "key_code": "c",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}
@XuPengfei-1020 XuPengfei-1020 changed the title From Ctrl + $Key is not workd from.optional is not optional Dec 26, 2024
@XuPengfei-1020 XuPengfei-1020 changed the title from.optional is not optional from.optional is not optional, it became required. Dec 26, 2024
@tekezo
Copy link
Member

tekezo commented Dec 28, 2024

This is by design. If optional is not specified, the modification only takes effect when the specified modifier state.
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/#examples

@XuPengfei-1020
Copy link
Author

XuPengfei-1020 commented Jan 2, 2025

@tekezo Thanks for your replay.

If optional is not specified, the modification only takes effect when the specified modifier state.

Could you please explain more about this rule?

https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/#with-modifiersmandatory
Here given a example of mapping control + h to delete_or_backspace , without from. modifiers.optional.
Can I map control + h to command + h without from. modifiers.optional?

Thank you.

@tekezo
Copy link
Member

tekezo commented Jan 5, 2025

Can I map control + h to command + h without from. modifiers.optional?

Specify to.modifiers:

{
    "description": "example",
    "manipulators": [
        {
            "from": {
                "key_code": "h",
                "modifiers": { "mandatory": ["control"] }
            },
            "to": [
                {
                    "key_code": "h",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}

@XuPengfei-1020
Copy link
Author

I know what this bug is.

If I set a rule like below (with out specify "optional": ["any"] in manipulators.from), this rule will be volatile.
It work firstly, but lose efficacy a few minutes later.
Everytime after I restart the karabiner, this rule will work as expect for few minutes (but then become volatile).

And, if I add a "optional": ["any"] in manipulators.from on this rule, the bug is disappeared, this rule will always work as expect.

Can I map control + h to command + h without from. modifiers.optional?

Specify to.modifiers:

{
    "description": "example",
    "manipulators": [
        {
            "from": {
                "key_code": "h",
                "modifiers": { "mandatory": ["control"] }
            },
            "to": [
                {
                    "key_code": "h",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}

@tekezo
Copy link
Member

tekezo commented Jan 6, 2025

Maybe a modifier key is unintentionally stuck?
When the rule stops working, what do the flags show in EventViewer?
Screenshot 2025-01-06 at 19 45 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants