改造 Mac 键位

2,020 阅读1分钟

使用 Shift 切换输入法

Mac 默认输入法使用 CapsLock 来切换中英文输入法,但如果你希望使用 Shift 来切换,只需要

  1. 安装 Karabiner
  2. mkdir -p ~/.config/karabiner/assets/complex_modifications
  3. 创建 shiftToSwitchInput.json,文件内容如下:
    {
      "title": "Shift to Switch Input",
      "rules": [
        {
          "description": "switch EN/ZH",
          "manipulators": [
            {
              "type": "basic",
              "from": {
                "key_code": "left_shift",
                "modifiers": {
                  "optional": [
                    "any"
                  ]
                }
              },
              "to": [
                {
                  "key_code": "left_shift",
                  "lazy": true
                }
              ],
              "to_if_alone": [
                {
                  "key_code": "spacebar",
                  "modifiers": [
                    "left_ctrl"
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
    
  4. 在 Karabiner 的设置中的 Complex Modification 点击 Add Rule,找到 switch EN/ZH 并启动,即可。

使用 Alt + Tab 切换应用

Mac 默认使用 Cmd + Tab 切换应用,想该用 Alt + Tab,只需要:

  1. 安装 Karabiner
  2. mkdir -p ~/.config/karabiner/assets/complex_modifications
  3. 创建 altTab.json,文件内容如下:
        {
          "title": "Remap App Switcher",
          "rules": [
                {
                  "description": "alt tab",
                  "manipulators": [
                    {
                      "from": {
                    "key_code": "tab",
                    "modifiers": {
                      "mandatory": [
                        "option"
                      ],
                      "optional": [
                        "any"
                      ]
                    }
                  },
                  "to": [
                    {
                      "key_code": "tab",
                      "modifiers": "control"
                    }
                  ],
                  "type": "basic"
                }
              ]
            }
          ]
        }
    
  4. 在 Karabiner 的设置中开启 Sticky Alt to Command Variable 和 Alt+Tab to change app

交换 Control 和 Command

系统设置 -> 键盘 -> 键盘快捷键 -> 修饰符 -> 选择键盘:Karabiner -> 改键位

注意,改键位之后,之前的 JSON 文件里面 control 和 command 也要全部交换位置。