Karabiner-elements: Mapping a key to a sequence of keys

Created on 26 Oct 2016  路  11Comments  路  Source: pqrs-org/Karabiner-Elements

Are there any plans to add support for mapping a key to a sequence of keys, for example, Cmd+A -> Cmd+B, Space, C?

Most helpful comment

OK, I finally found it. Apparently, it matters where you put the sequence. Editing ~/.config/karabiner, if you want to map to a sequence, add to profiles.complex_modifications.rules key. For example:

"rules": [
    {
        "manipulators": [
            {
                "description": "Change right shift to a + enter",
                "from": {
                    "key_code": "right_shift",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "a"
                    },
                    {
                        "key_code": "return_or_enter"
                    }
                ],
                "type": "basic"
            }
        ]
    }
]

All 11 comments

See #16

Thanks, @talha131, but I'm looking for something different. Instead of mapping multiple keys to one, I want to map one shortcut to multiple separate keys.

369

I'm not looking to use this in a terminal, but thanks for the link anyway.

Guys, I can't find a way how to map a key to a sequence of keys. @tekezo link doesn't help, that issue just mentions release, not how to set it up. And documentation is lacking as well, word "sequence" is not present in the whole documentation file so please elaborate how do you achieve mapping to a sequence.

I tried putting both two strings in keycode array, didn't work. I tried listing two entries in "to" array, didn't work either...

If nobody answers I'll raise a new ticket and complain about it there :)

Cheers

OK, I finally found it. Apparently, it matters where you put the sequence. Editing ~/.config/karabiner, if you want to map to a sequence, add to profiles.complex_modifications.rules key. For example:

"rules": [
    {
        "manipulators": [
            {
                "description": "Change right shift to a + enter",
                "from": {
                    "key_code": "right_shift",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "a"
                    },
                    {
                        "key_code": "return_or_enter"
                    }
                ],
                "type": "basic"
            }
        ]
    }
]

add a new config :

{
  "manipulators": [
    {
      "description": "Change escape to shift + f1.",
      "from": {
        "key_code": "escape",
        "modifiers": {
          "optional": ["any"]
        }
      },
      "to": [
        {
          "key_code": "f1",
          "modifiers": ["left_shift"]
        }
      ],
      "type": "basic"
    }
  ]
}

Both @revelt and @houfeng0923 correctly suggested. I just added a tip of instructions for beginners:

  1. cd ~/.config/karabine
  2. vi karabiner.json
  3. find key named rules. It would looks like this:
{
// ...
"complex_modifications": {
                 "parameters": {
                     "basic.simultaneous_threshold_milliseconds": 50,
                     "basic.to_delayed_action_delay_milliseconds": 500,
                     "basic.to_if_alone_timeout_milliseconds": 1000,
                     "basic.to_if_held_down_threshold_milliseconds": 500,
                     "mouse_motion_to_scroll.speed": 100
                 },
                 "rules": []
             },
// ...
}
  • it could be non-empty array, of course.
  • add a modification in array:
{
// ...
"complex_modifications": {
                 "parameters": {
                     "basic.simultaneous_threshold_milliseconds": 50,
                     "basic.to_delayed_action_delay_milliseconds": 500,
                     "basic.to_if_alone_timeout_milliseconds": 1000,
                     "basic.to_if_held_down_threshold_milliseconds": 500,
                     "mouse_motion_to_scroll.speed": 100
                 },
                 "rules": [ 
                          {
                             "manipulators": [
                                 {
                                     "description": "Change right shift to a + enter",
                                     "from": {
                                         "key_code": "right_shift",
                                         "modifiers": {
                                             "optional": [
                                                 "any"
                                             ]
                                         }
                                     },
                                     "to": [
                                         {
                                             "key_code": "a"
                                         },
                                         {
                                             "key_code": "return_or_enter"
                                         }
                                     ],
                                     "type": "basic"
                                 }
                             ]
                         }
                  ]
             },
// ...
}
  1. you can find the result in GUI karabiner-elements - modification tab - rules sub-tab.

very helpful bit of copy-pasteable code, thank you @roeniss. Only thing is you dropped an r in cd ~/.config/karabine.

Oh you re right!! Why I did that?!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

willisworley picture willisworley  路  3Comments

Ox0400 picture Ox0400  路  3Comments

PSalant726 picture PSalant726  路  3Comments

rkusa picture rkusa  路  3Comments

LittleNewton picture LittleNewton  路  3Comments