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.91k stars 839 forks source link

Problem with "Spacebar to modifiers if pressed with other keys" #2977

Open ww7 opened 2 years ago

ww7 commented 2 years ago

With complex modification Spacebar to modifiers if pressed with other keys very often spacebar is not keyUp in time and false activations are triggered.

Which timeout settings can improve recognizing to_if_alone? If possible to set minimal keyDown delay?

I use spacebar as complex modifier (Cmd+Ctrl+Opt) and need to post a space if it pressed alone.

ww7 commented 2 years ago

If it is possible to implement logic close to if_not_alone approach?

ww7 commented 2 years ago

Seems I need option for minimum keydown delay or minimum timout of "not pressed any keys" before trigger.

ww7 commented 2 years ago

Ah, seems I need to-if-held-down https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to-if-held-down/

martin-hoger commented 2 years ago

Serhii, it is a really great idea. Did it work for you? Would you post the code here?

ldebritto commented 2 years ago

Hey, @ww7 , did you manage to get this working fine with the to-if-held-down path? I like the idea of using the spacebar as a mod key, but I also find that it triggers too many false positives as well. Meanwhile, I'm still trusting caps as hyper.

tshu-w commented 1 year ago

@martin-hoger @ldebritto Here is an example gist that I have been using for four years. I also make a PR to https://github.com/pqrs-org/KE-complex_modifications/pull/1436

ww7 commented 2 weeks ago

Yes, such adjusting works good. It can be globally configured on KE app or specifically inside CM, e.g.:

    "parameters": {
        "basic.to_delayed_action_delay_milliseconds": 150,
        "basic.to_if_alone_timeout_milliseconds": 300,
        "basic.to_if_held_down_threshold_milliseconds": 150
    }

You can decide to make delays bigger (e.g. 200,400,200) if typing slow or older Mac with slower CPU.

Placement delays:

{
    "description": "Spacebar to Ctrl+Opt+Cmd modifiers if pressed with other keys or space if pressed alone)",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.parallels\\.desktop\\.console$"
                    ],
                    "type": "frontmost_application_unless"
                }
            ],
            "from": {
                "key_code": "spacebar",
                "modifiers": { "optional": ["any"] }
            },
            "to": [
                {
                    "key_code": "left_command",
                    "modifiers": ["left_control", "left_option"]
                }
            ],
            "to_if_alone": [{ "key_code": "spacebar" }],
            "to_if_held_down": [{ "key_code": "spacebar" }],
            "type": "basic"
        }
    ],
    "parameters": {
        "basic.to_delayed_action_delay_milliseconds": 150,
        "basic.to_if_alone_timeout_milliseconds": 300,
        "basic.to_if_held_down_threshold_milliseconds": 150
    }
}

Using Ctrl+Opt+Cmd modifiers allows to have additional layer if Spacebar pressed with Shift that works as Ctrl+Opt+Cmd+Shift.

To easy launch apps with this I recommend Keyboard Cowboy or older Apptivate shortcuts managers.