4

I have been using Karabiner for some key remappings on a macbook pro. I have successfully (and very satisfyingly) remapped right-cmd + up arrow and right-cmd + down arrow to page up and page down.

I would like to do further remappings, such as remap shift + enter so that it will give me line breaks in messages, or cmd + anglebrackets to switch workspaces. Unfortunately the only way I know to do these things are with two key strokes in the first place (option + enter for messages new lines and control + arrow keys to switch workspaces). How can I use karabiner to make two key presses map to two other key presses?

2 Answers 2

4

Ok I solved my two specific problems, though I am still not sure how I would replicate multiple key presses if more than one of them were not modifier keys.

Put the following two json files in user/.config/karabiner/assets/complex_modifications

{
  "title": "Shift + Enter",
  "rules": [
    {
      "description": "Shift + Enter to Option Enter (newline in messenger)",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "return_or_enter",
            "modifiers": {
              "mandatory": [
                "shift"
              ],
              "optional": [
                "caps_lock",
                "option"
              ]
            }
          },
          "to": [
            {
              "key_code": "return_or_enter",
              "modifiers": [
                "option"
            ]
            }
          ]
        }
      ]
    }
  ]
}

This one (shift enter) is really frustrating me but not because of karabiner. In messenger i need to option+enter to get a new line character, but in the browser option-enter refuses to do anything. I wish I could get a key combination that does a consistent "safe" new line character, rather than making me fear I am going to accidentally press enter to send or complete or publish or something like that.

{
  "title": "cmd + angle brackets for workspaces",
  "rules": [
    {
      "description": "Use CMD + comma  (left angle bracket key) to switch to  left workspace",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "comma",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "caps_lock",
                "option",
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow",
              "modifiers": [
                "control"
            ]
            }
          ]
        }
      ]
    },
    {
      "description": "Use CMD + .  (right angle bracket key) to switch to  left workspace",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "period",
            "modifiers": {
              "mandatory": [
                "command"
              ],
              "optional": [
                "caps_lock",
                "option",
                "control"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow",
              "modifiers": [
                "control"
            ]
            }
          ]
        }
      ]
    }
  ]
}

A solution to a similar question can be found here: How to bind a key to press two separate keys

1

You can send multiple key codes like so in the to array. In this example, I'm using the Insert key (on my Microsoft keyboard) to send the characters in hello one at a time.

{
    "description": "(Terminal) Insert",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com\\.apple\\.Terminal$"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "insert"
            },
            "to": [
                {
                    "key_code": "h"
                },
                {
                    "key_code": "e"
                },
                {
                    "key_code": "l"
                },
                {
                    "key_code": "l"
                },
                {
                    "key_code": "o"
                }
            ],
            "type": "basic"
        }
    ]
}
4
  • 1
    Welcome! Thanks for taking the time to answer. It’s helpful to put a short explanation so that readers of different technical proficiencies can grasp what you’re trying to convey.
    – Allan
    Jan 7, 2023 at 20:49
  • It looks like the later ones override the previous ones
    – minseong
    Apr 17, 2023 at 0:46
  • @theonlygusti I'm no expert here, but the example I showed in the answer certainly works for me, and emits each character in order.
    – stubert
    Apr 20, 2023 at 15:59
  • @stubert I believe you, it looks like something funky happens for the function key though
    – minseong
    Apr 20, 2023 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .