macbook 按右边shift 切换为中文输入法, 左边shift 英文输入法, 如何做到?

我的电脑是mac, 我希望 按右边shift 切换为中文输入法, 左边shift 英文输入法, 如何做到

以前我用的是 Karabiner-Elements, 但是后来某天 ,不知道为什么 失效了, 我就干脆不用它了, 换手动切换输入法了

但是现在经常切换输入法,老是切换不到点上,还是挺累的, 想问问大家用的啥方案, 有啥推荐的吗

谢谢

16 Likes

一个shift就行,当然,你也可以按需修改配置:

步骤:

  1. 进入 ~/.config/karabiner/assets/complex_modifications
  2. 创建新文件 input_switch.json
  3. 添加如下配置(第一段配置即可满足你的需求)
  4. 在Karabiner中导入该配置并开启即可
{
  "title": "Switch input source  |  输入法切换",
  "rules": [
    {
      "description": "Tap Shift_L (⇧) → Switch input source (F18)  |  短按左 Shift (⇧) → 切换输入法 ",
      "manipulators": [
        {
          "from": {
            "key_code": "left_shift",
            "modifiers": {
              "optional": ["caps_lock"]
            }
          },
          "to": [
            {
              "key_code": "left_shift"
            }
          ],
          "to_if_alone": [
            {
              "key_code": "f18"
            }
          ],
          "to_if_held_down": [
            {
              "key_code": "left_shift"
            }
          ],
          "type": "basic"
        }
      ]
    },
    {
      "description": "Tap Shift_R (⇧) → Switch input source (F18)  |  短按右 Shift (⇧) → 切换输入法",
      "manipulators": [
        {
          "from": {
            "key_code": "right_shift",
            "modifiers": {
              "optional": ["caps_lock"]
            }
          },
          "to": [
            {
              "key_code": "right_shift"
            }
          ],
          "to_if_alone": [
            {
              "key_code": "f18"
            }
          ],
          "to_if_held_down": [
            {
              "key_code": "right_shift"
            }
          ],
          "type": "basic"
        }
      ]
    },
    {
      "description": "Command_L (⌘) + Space → Switch input source (F18)  |  左 Command (⌘) + 空格 → 切换输入法",
      "manipulators": [
        {
          "from": {
            "key_code": "spacebar",
            "modifiers": {
              "mandatory": ["left_command"],
              "optional": ["caps_lock"]
            }
          },
          "to": [
            {
              "key_code": "f18"
            }
          ],
          "type": "basic"
        }
      ]
    },
    {
      "description": "Command_R (⌘) + Space → Switch input source (F18)  |  右 Command (⌘) + 空格 → 切换输入法",
      "manipulators": [
        {
          "from": {
            "key_code": "spacebar",
            "modifiers": {
              "mandatory": ["right_command"],
              "optional": ["caps_lock"]
            }
          },
          "to": [
            {
              "key_code": "f18"
            }
          ],
          "type": "basic"
        }
      ]
    }
  ]
}

其他:
可以在系统这里设置输入法切换快捷键为一个不存在的键 F18,避免与其他冲突

2 Likes

你好, 现在的搜狗、微信输入法 自身通过设置 也可以用一个按钮切换输入法

我想实现的是 对应的按键 绑定固定的输入法

因为有时候我不知道我的输入法当前状态,准备写代码,结果打出了中文

有时候准备 和人聊天, 结果打出了拼音

所以我才想把固定按键绑定到固定的输入法 状态上

如此的话,我可以根据需要 按某个按键,输入法一定是我想要的状态

感谢回复

我是设置左opt英文, 右cmd中文, 好像要先设置只保留两个输入法, 并且f18切换下个输入法

{
    "description": "left_option to English, right_command to Simplified Chinese",
    "manipulators": [
        {
            "conditions": [
                {
                    "input_sources": [{ "language": "zh-Hans" }],
                    "type": "input_source_if"
                }
            ],
            "from": {
                "key_code": "left_option",
                "modifiers": { "optional": ["any"] }
            },
            "parameters": {
                "basic.to_if_alone_threshold_milliseconds": 0,
                "basic.to_if_alone_timeout_milliseconds": 300,
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "left_option",
                    "lazy": true
                }
            ],
            "to_if_alone": [{ "key_code": "f18" }],
            "to_if_held_down": [{ "key_code": "left_option" }],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "input_sources": [{ "language": "en" }],
                    "type": "input_source_if"
                }
            ],
            "from": {
                "key_code": "right_command",
                "modifiers": { "optional": ["any"] }
            },
            "parameters": {
                "basic.to_if_alone_threshold_milliseconds": 0,
                "basic.to_if_alone_timeout_milliseconds": 300,
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "right_command",
                    "lazy": true
                }
            ],
            "to_if_alone": [{ "key_code": "f18" }],
            "to_if_held_down": [{ "key_code": "right_command" }],
            "type": "basic"
        }
    ]
}

顺便加个input source pro提示 :tieba_025:

你可能需要一个随应用自动切换输入法的软件:AutoSwitchInput

谢谢大家, 根据楼上几位好心人的提点, 我整理了一份配置,可以实现我的需求,现分享出来:

(注:最后发现用拇指按 command 好过小指按shift,所以我就用 左右command来切换输入法了 )

{
    "description": "Left Command to English, Right Command to Chinese",
    "manipulators": [
        {
            "from": {
                "key_code": "left_command",
                "modifiers": { "optional": ["any"] }
            },
            "parameters": {
                "basic.to_if_alone_threshold_milliseconds": 0,
                "basic.to_if_alone_timeout_milliseconds": 300,
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "left_command",
                    "lazy": true
                }
            ],
            "to_if_alone": [{ "select_input_source": { "language": "en" } }],
            "to_if_held_down": [{ "key_code": "left_command" }],
            "type": "basic"
        },
        {
            "from": {
                "key_code": "right_command",
                "modifiers": { "optional": ["any"] }
            },
            "parameters": {
                "basic.to_if_alone_threshold_milliseconds": 0,
                "basic.to_if_alone_timeout_milliseconds": 300,
                "basic.to_if_held_down_threshold_milliseconds": 100
            },
            "to": [
                {
                    "key_code": "right_command",
                    "lazy": true
                }
            ],
            "to_if_alone": [{ "select_input_source": { "language": "zh-Hans" } }],
            "to_if_held_down": [{ "key_code": "right_command" }],
            "type": "basic"
        }
    ]
}

使用这个配置的时候,建议禁用系统的输入法快捷键,也禁用 你所使用的对应中文输入法的快捷键,以免互相干扰

这份配置,我目前测试 没发现什么问题, 大家如果遇到问题,可在此帖子下留言给我, 谢谢