pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful tool for customizing keyboards on macOS
https://karabiner-elements.pqrs.org/
The Unlicense
18.93k stars 839 forks source link

Mandatory modifiers are not removed from to events #3993

Closed ln613 closed 3 weeks ago

ln613 commented 3 weeks ago

The documentation says:

"Mandatory modifiers are removed from to events."

However, it doesn't seem to be the case, if I do sth like this

... "from": { "key_code": "left_arrow", "modifiers": { "mandatory": ["left_command"] } }, "to": [{ "key_code": "home" }], ...

It will be changed to "left_command + home", the modifiers are kept. How do I remove the Mandatory modifiers?

tekezo commented 3 weeks ago

The setting works well on my machine, changes left_command+left_arrow to home. Is there a Complex Modifications rule defined above this one that is altering left_arrow?

ln613 commented 3 weeks ago

I removed all other modifications, and it's still the same

{ "profiles": [ { "complex_modifications": { "rules": [ { "description": "F keys", "manipulators": [ { "from": { "key_code": "left_arrow", "modifiers": { "mandatory": ["left_command"] } }, "to": [{ "key_code": "home" }], "type": "basic" } ] } ] }, "name": "Default profile", "selected": true, "virtual_hid_keyboard": { "keyboard_type_v2": "ansi" } } ] }

When I press left_command + left_arrow in event viewer, I got left_command + home

image
tekezo commented 3 weeks ago

It's home.

The EventViewer shows flags when left_command + home is pressed.

Screenshot 2024-11-01 at 8 58 20
ln613 commented 3 weeks ago

you are right, it is home. but sent after a left_command DOWN is send, followed by the home UP and left_command UP. So it's equivalent to pressing home and left_command separately.

It won't cause any problem on Mac since pressing left_command alone doesn't do anything, but when I use it inside a Remote Desktop app running windows, the command button becomes the WIN button in windows, which will open the task bar when the left_command UP is finally sent.

Is there a way to prevent the left_command UP being sent after a modification happened?

tekezo commented 3 weeks ago

There are a few ways to do this, the easiest is to change left_command itself to a lazy modifier. https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/lazy/

tekezo commented 3 weeks ago

Another option is to use simultaneous so that it only triggers home when keys are pressed at the same time. https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/simultaneous/