How to exchange square bracket and curly bracket (karabiner)

1.2k Views Asked by At

On Karabiner rules (https://pqrs.org/osx/karabiner/complex_modifications/), there is a rule for Exchange paren and square bracket but there is no rule for Exchange square bracket and curly braket.

[Q] How to exchange square bracket and curly bracket through Karabiner or any alternative?

Wanted exchange:

  • [ => { and { => [
  • ] => } and } => ]
1

There are 1 best solutions below

7
On BEST ANSWER

This code works for me

{
  "description": "Swap {} and []",
  "manipulators": [
    {
      "type": "basic",
      "from": {
        "key_code": "open_bracket"
      },
      "to": [
        {
          "modifiers": ["left_shift"],
          "key_code": "open_bracket"
        }
      ]
    },
    {
      "type": "basic",
      "from": {
        "key_code": "open_bracket",
        "modifiers": {
          "mandatory": ["left_shift"]
        }
      },
      "to": [
        {
          "key_code": "open_bracket"
        }
      ]
    },
    {
      "type": "basic",
      "from": {
        "key_code": "close_bracket"
      },
      "to": [
        {
          "modifiers": ["left_shift"],
          "key_code": "close_bracket"
        }
      ]
    },
    {
      "type": "basic",
      "from": {
        "key_code": "close_bracket",
        "modifiers": {
          "mandatory": ["left_shift"]
        }
      },
      "to": [
        {
          "key_code": "close_bracket"
        }
      ]
    }
  ]
}

edit: also now in complex mod list https://pqrs.org/osx/karabiner/complex_modifications/#exchange_square_brackets_and_curly_brackets