Karabiner-elements: How to map "left_shift" to "Option+space"?

Created on 28 Jun 2017  路  4Comments  路  Source: pqrs-org/Karabiner-Elements

I am using Karabiner-Elements beta version (0.91.4) on macOS Sierra (10.12.5). I have two input sources and set Option+Space to switch the input source in the Shortcuts setting in System Preferences.

I'd like to set the left_shift key in a way such that:

  • short left_shift keypress = Option + Space
  • long left_shift keypress + other key = Shift + other key

I tried to map the left_shift key with the following configuration in my karabiner.json file.

{
  "global": {
    "check_for_updates_on_startup": true,
    "show_in_menu_bar": true,
    "show_profile_name_in_menu_bar": false
  },
  "profiles": [
    {
      "complex_modifications": {
        "rules": [
          {
            "manipulators": [
              {
                "description": "Change left_shift to option+space, to left_shift when used alone",
                "from": {
                  "key_code": "left_shift",
                  "modifiers": {
                    "optional": [
                      "any"
                    ]
                  }

                },
                "to": [
                  {
                    "key_code": "spacebar",
                    "modifiers": {
                      "mandatory": [
                        "left_option"
                      ]
                    }

                  }
                ],
                "to_if_alone": [
                  {
                    "key_code": "left_shift",
                    "modifiers": {
                      "optional": [
                        "any"
                      ]
                    }
                  }
                ],
                "type": "basic"
              }
            ]
          }
        ]
      },
      "devices": [],
      "fn_function_keys": {
        "f1": "display_brightness_decrement",
        "f10": "mute",
        "f11": "volume_decrement",
        "f12": "volume_increment",
        "f2": "display_brightness_increment",
        "f3": "mission_control",
        "f4": "launchpad",
        "f5": "illumination_decrement",
        "f6": "illumination_increment",
        "f7": "rewind",
        "f8": "play_or_pause",
        "f9": "fastforward"
      },
      "name": "",
      "selected": false,
      "simple_modifications": {},
      "virtual_hid_keyboard": {
        "caps_lock_delay_milliseconds": 0,
        "keyboard_type": "ansi"
      }
    }
  ]
}

However, the configuration does not work. When I press left_shift, I always
get a single space.

Could you help check this configuration? Where did I do wrong?

Thank you!

Most helpful comment

"to": [
    {
        "key_code": "spacebar",
        "modifiers": [
            "left_option"
        ]
    }
],

Note there is no "mandatory" in "to". See this example: https://github.com/tekezo/Karabiner-Elements/blob/master/examples/caps_lock_to_command_control_option_shift.json

All 4 comments

"to": [
    {
        "key_code": "spacebar",
        "modifiers": [
            "left_option"
        ]
    }
],

Note there is no "mandatory" in "to". See this example: https://github.com/tekezo/Karabiner-Elements/blob/master/examples/caps_lock_to_command_control_option_shift.json

Yes! This solves my problem! Thank you so much. I am closing this issue now.

{
  "global": {
    "check_for_updates_on_startup": true,
    "show_in_menu_bar": true,
    "show_profile_name_in_menu_bar": false
  },
  "profiles": [
    {
      "complex_modifications": {
        "rules": [
          {
            "manipulators": [
              {
                "description": "Change left_shift to option+space, to left_shift when used alone",
                "from": {
                  "key_code": "left_shift",
                  "modifiers": {
                    "optional": [
                      "any"
                    ]
                  }

                },
                "to": [
                  {
                    "key_code": "spacebar",
                    "modifiers": [
                        "left_option"
                    ]
                  }
                ],
                "to_if_alone": [
                  {
                    "key_code": "left_shift",
                    "modifiers": {
                      "optional": [
                        "any"
                      ]
                    }
                  }
                ],
                "type": "basic"
              },
              {
                "description": "Change left_shift to option+space, to left_shift when used alone",
                "from": {
                  "key_code": "left_shift",
                  "modifiers": {
                    "optional": [
                      "any"
                    ]
                  }
                },
                "to": [
                  {
                    "key_code": "spacebar",
                    "modifiers": {
                      "mandatory": [
                        "left_option"
                      ]
                    }

                  }
                ],
                "to_if_alone": [
                  {
                    "key_code": "left_shift",
                    "modifiers": {
                      "optional": [
                        "any"
                      ]
                    }
                  }
                ],
                "type": "basic"
              }
            ]
          }
        ]
      },
      "devices": [],
      "fn_function_keys": {
        "f1": "display_brightness_decrement",
        "f10": "mute",
        "f11": "volume_decrement",
        "f12": "volume_increment",
        "f2": "display_brightness_increment",
        "f3": "mission_control",
        "f4": "launchpad",
        "f5": "illumination_decrement",
        "f6": "illumination_increment",
        "f7": "rewind",
        "f8": "play_or_pause",
        "f9": "fastforward"
      },
      "name": "",
      "selected": false,
      "simple_modifications": {},
      "virtual_hid_keyboard": {
        "caps_lock_delay_milliseconds": 0,
        "keyboard_type": "ansi"
      }
    }
  ]
}

I cannot get capital letters when I press left_shift key + letters ...

Yeah I haven't noticed it either. So what you actually want is: shift acts like shift if pressed with other keys, and acts like space + option if pressed alone.

So you should do shift "to" shift, and shift "to_if_alone" space + option. Now you are doing the opposite of that.

@apm1467 Thanks for your help. I've made it work by switching the two parts. Sorry for such a sloppy mistake..

Was this page helpful?
0 / 5 - 0 ratings