Karabiner-Elements map a key to a combination keys

11.3k views Asked by At

I'm new to Karabiner. As I understand it this program can change the keyboard mapping. I understand and able to use the "Simple modification" "From key" "To key".

But If I want to remap my Home button to CTRL+LEFT_ARROW how do I do that?

Currently on MacOs Mojave

2

There are 2 answers

0
RonPringadi On BEST ANSWER

Open ~/.config/karabiner/karabiner.json Edit that file, from the root level > "profiles" > "complex_modifications" > under parameters:{ ... }, add:

"rules": [
                    {
                        "description": "Home to Control Left",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "home"
                                },
                                "to": [
                                    {
                                        "key_code": "left_arrow",
                                        "modifiers": "control"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    },
                    {
                        "description": "End to Control Right",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "end"
                                },
                                "to": [
                                    {
                                        "key_code": "right_arrow",
                                        "modifiers": "control"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]

Please note that, this will map:

  • HOME to CTRL+LEFT
  • END to CTRL+RIGHT
0
Noel Yap On

Create ~/.config/karabiner/line.json as:

{
  "title": "Line-related mappings",
  "rules": [
    {
      "description": "Home to Cmd+Left: Move to line start",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "home",
            "modifiers": {
              "optional": [
                "caps_lock"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow",
              "modifiers": "command"
            }
          ]
        }
      ]
    },
    {
      "description": "Shift+Home to Shift+Cmd+Left: Select to line start",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "home",
            "modifiers": {
              "mandatory": [
                "shift"
              ],
              "optional": [
                "caps_lock"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow",
              "modifiers": [
                "shift",
                "command"
              ]
            }
          ]
        }
      ]
    },
    {
      "description": "End to Cmd+Right: Move to line end",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "end",
            "modifiers": {
              "optional": [
                "caps_lock"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow",
              "modifiers": "command"
            }
          ]
        }
      ]
    },
    {
      "description": "Shift+End to Shift+Cmd+Right: Select to line end",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "end",
            "modifiers": {
              "mandatory": [
                "shift"
              ],
              "optional": [
                "caps_lock"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow",
              "modifiers": [
                "shift",
                "command"
              ]
            }
          ]
        }
      ]
    }
  ]
}

Then in Karabiner, go to Preferences -> Complex Modifications -> Add Rules -> Enable All.

The above and others can be found in https://github.com/noel-yap/karabiner.