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.88k stars 838 forks source link

Combining Conditions #2725

Open Muirium opened 3 years ago

Muirium commented 3 years ago

Hi, I'm trying to combine two condition types: device_if and keyboard_type_if

I want to apply the following rules on all Apple made keyboards which are ISO layout. So not on ISO keyboards in general, and not on Apple keyboards which are ANSI.

Unfortunately, I can't seem to combine both if conditions. This works: { "description": "💻 Apple Keyboard: ⇨ ⇧ Right Shift or when alone", "manipulators": [ { "conditions": [ { "type": "keyboard_type_if", "keyboard_types": ["iso"] } ], "type": "basic", "from": { "key_code": "grave_accent_and_tilde", "modifiers": { "optional": [ "any" ] } }, "to": [ { "key_code": "right_shift", "lazy": true } ], "to_if_alone": [ { "key_code": "grave_accent_and_tilde" } ] } ] } And this works: { "description": "💻 Apple Keyboard: § ⇨ (Fn to override)", "manipulators": [ { "conditions": [ { "type": "device_if", "identifiers": [ { "vendor_id": 1452 } ] } ], "type": "basic", "from": { "key_code": "non_us_backslash", "modifiers": { "mandatory": [ "fn" ], "optional": [ "any" ] } }, "to": [ { "key_code": "non_us_backslash" } ] }, { "conditions": [ { "type": "device_if", "identifiers": [ { "vendor_id": 1452 } ] } ], "type": "basic", "from": { "key_code": "non_us_backslash", "modifiers": { "optional": [ "any" ] } }, "to": [ { "key_code": "grave_accent_and_tilde" } ] } ] } ` But putting both device_if and keyboard_type_if into the conditions statement does NOT work. Nor does using two conditions statements in sequence within the same rule.

So I'm stumped! Anyone know how to do this?

(These rules are designed to extend the Left Shift key which Iind a bit short on ISO, and to turn § into ` except when I hold Fn to override it.)

(Also: apologies for my code showing up all wrong. I don't know what's up with the surrounding ' tags.)

MuhammedZakir commented 3 years ago

Try:

  "conditions": [
    {
      "type": "device_if",
      "identifiers": [
        {
          "vendor_id": 1452
        }
      ]
    },
    {
      "type": "keyboard_type_if",
      "keyboard_types": [
        "iso"
      ]
    }
  ]

When adding a multi-line code, use code block tag - triple backticks (```).

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.