pqrs-org / Karabiner-Elements

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

How to use apple global/language key as an outgoing modifier in complex modification #3940

Closed popbones closed 1 month ago

popbones commented 2 months ago

I’m trying to setup shortcuts to some new macOS window management shortcuts which heavily involves the global key found on modern Mac keyboards. I think in Karabiner, the key code is:

{
  "apple_vendor_keyboard_key_code": "language"
}

For example, to arrange window as left half of the screen, the default keyboard shortcut is ctrl + language + left_arrow.

I have been successful in mapping the “application” key on my full size PC keyboard to the language key by itself via simple modification. It works just fine as in I have no trouble to trigger the key combo.

However, I’m trying to map the same key to a DualShock 4 controller and I need to use complex modification because I want to use one button to cycle through a list of layouts.

The problem however is that I couldn’t figure out how to use the language key as a modifier.

For sake of the discussion, let’s say I want to a Complex Modification Manipulator to emit ctrl + language + f which is the macOS 15 shortcut to make a window “fill the screen”.

image image
tekezo commented 2 months ago

The globe key (fn key) handling has issue, and it is solved in the latest beta version. https://github.com/pqrs-org/Karabiner-Elements/issues/3879#issuecomment-2381071748

You can use "modifiers": ["fn"] or "key_code": "fn" to use the globe key. For example, the following json changes shift+f11 to control+fn+left arrow.

        {
            "from": {
                "key_code": "f11",
                "modifiers": {
                    "mandatory": ["left_shift"],
                    "optional": ["any"]
                }
            },
            "to": [
                {
                    "key_code": "left_arrow",
                    "modifiers": ["fn", "left_control"]
                }
            ],
            "type": "basic"
        }
popbones commented 2 months ago

Thank you for the quick reply.

I'll try that tomorrow and update the issue afterwords.

On a side note, is the language key always the same as fn key?

To clarify my question. What I mean is the following:

  1. If an Apple keyboard has an fn key but not a global key, does it use the same key code as the language key?

  2. If an Apple keyboard has a language key with the global icon but not an fn key. (A bit of a stretch, but I think the iPad Magic Keyboard thing is like that). Are they the same key in this case?

  3. What about PC keyboards? Do they use the same key code?

Thanks.

tekezo commented 1 month ago
popbones commented 1 month ago

@tekezo Thank you very much.

I've confirmed v15.0.17 works fine for me. Closing the issue.