Mac上用CapsLock切换搜狗输入法

林一二2020年06月22日 12:38
Ref: LinOnetwo
Keywords:

需要使用 karabiner-elements

通过 open ~/.config/karabiner/karabiner.json 打开配置文件,黏贴如下的配置。

之后在 Preference - Complex modifications 里点击 Add rule 即可添加用CapsLock切换输入法的功能。

想写更多配置可以到官方配置列表抄。

查看引文:karabiner.json

{
  "global": {
    "check_for_updates_on_startup": true,
    "show_in_menu_bar": true,
    "show_profile_name_in_menu_bar": false
  },
  "profiles": [
    {
      "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 caps_lock to command+space to invoke IME switch if pressed alone.",
                "from": {
                  "key_code": "caps_lock",
                  "modifiers": {
                    "optional": ["any"]
                  }
                },
                "to_if_alone": [
                  {
                    "key_code": "spacebar",
                    "modifiers": ["left_command"]
                  }
                ],
                "type": "basic"
              }
            ]
          },
          {
            "description": "Change caps_lock to command+control+option+shift if pressed with other keys.",
            "manipulators": [
              {
                "type": "basic",
                "from": {
                  "key_code": "l",
                  "modifiers": {
                    "mandatory": ["option"]
                  }
                },
                "to": [
                  {
                    "key_code": "q",
                    "modifiers": ["left_control", "left_command"]
                  }
                ]
              }
            ]
          },
          {
            "description": "Change right_shift to command+left_shift if pressed with other keys, and toggle IME if pressed alone.",
            "manipulators": [
              {
                "type": "basic",
                "from": {
                  "key_code": "right_shift",
                  "modifiers": {
                    "optional": ["any"]
                  }
                },
                "to": [
                  {
                    "key_code": "left_shift",
                    "modifiers": ["left_command"]
                  }
                ],
                "to_if_alone": [
                  {
                    "key_code": "spacebar",
                    "modifiers": ["left_command"]
                  }
                ]
              }
            ]
          },
          {
            "description": "Lock screen using left_command + L instead of Ctrl + Command + Q",
            "manipulators": [
              {
                "type": "basic",
                "from": {
                  "key_code": "l",
                  "modifiers": ["left_command"]
                },
                "to": [
                  {
                    "key_code": "q",
                    "modifiers": ["left_command", "left_control"]
                  }
                ]
              }
            ]
          }
        ]
      },
      "devices": [],
      "fn_function_keys": [],
      "name": "Default profile",
      "parameters": {
        "delay_milliseconds_before_open_device": 1000
      },
      "selected": true,
      "simple_modifications": [],
      "virtual_hid_keyboard": {
        "country_code": 0,
        "mouse_key_xy_scale": 100
      }
    }
  ]
}
Code
需要使用 [[karabiner-elements|https://github.com/pqrs-org/Karabiner-Elements]]

通过 `open ~/.config/karabiner/karabiner.json` 打开配置文件,黏贴如下的配置。

之后在 Preference - Complex modifications 里点击 Add rule 即可添加用CapsLock切换输入法的功能。

想写更多配置可以到[[官方配置列表|https://ke-complex-modifications.pqrs.org/#modifier-keys]]抄。

<<reuse-tiddler "karabiner.json">>