鼠标macOS下定义快捷键(各品牌通用)

2023-05-16

雷蛇鼠标在驱动在macOS下支持不太好,最高只能安装雷云2,用户体验不太好。每次开机要拔掉鼠标重新安装才可以识别鼠标。

关于macOS下安装雷云2见我以前的这篇文章:
《macOS Big Sur中雷蛇鼠标驱动 雷云2.0无法正常使用解决办法与mac雷蛇卸载》
https://blog.csdn.net/lxyoucan/article/details/112403568

那么有没有什么方法可解决macOS下鼠标按键定义呢?答案是可以。

Karabiner-Elements

适用于 macOS 的强大且稳定的键盘定制器。
https://karabiner-elements.pqrs.org/

启用鼠标

默认是没有启用鼠标设置的,可以在这里启用。
适用于 macOS 的强大且稳定的键盘定制器。
在这里插入图片描述

设置鼠标

示例1 设置成a,b键

在这里插入图片描述
如上图,我把侧面按键设置成a和b。

在这里插入图片描述
这样鼠标侧面按键就成a和b 了。

示例2 设置成左右键

在这里插入图片描述

示例3 切换macOS虚拟桌面

显然上面的单键映射无法满足我,我需要使用鼠标左侧的按键来切换虚拟桌面。如何实现呢?
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

微调配置

这个配置可能不完全符合我们的要求,如何来修改呢?
在这里插入图片描述

可以直接去修改这个json,修改完这个json后,放到以下这个页面的输入框之中。
https://genesy.github.io/karabiner-complex-rules-generator/

在这里插入图片描述
粘贴完成以后,点击INSTSLL!

在这里插入图片描述

在这里插入图片描述

我的json配置分享:

{
  "title": "ITKEY Mouse 3/4/5 desktop switcher",
  "rules": [
    {
      "description": "Mouse 5 Switch Left",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "pointing_button": "button5"
          },
          "to": [
            {
              "repeat": false,
              "key_code": "left_arrow",
              "modifiers": [
                "left_control"
              ]
            }
          ]
        }
      ]
    },
    {
      "description": "Mouse 4 Switch Right",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "pointing_button": "button4"
          },
          "to": [
            {
              "repeat": false,
              "key_code": "right_arrow",
              "modifiers": [
                "left_control"
              ]
            }
          ]
        }
      ]
    },
    {
      "description": "Mouse 3 Desktop Switcher",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "pointing_button": "button3"
          },
          "to": [
            {
              "repeat": false,
              "key_code": "up_arrow",
              "modifiers": [
                "left_control"
              ],
              "lazy": false
            }
          ]
        }
      ]
    }
  ]
}

好用的配置

Caps Lock → Hyper Key (⌃⌥⇧⌘) (Caps Lock if alone)

{
  "title": "Caps Lock → Hyper Key (⌃⌥⇧⌘) (Caps Lock if alone)",
  "rules": [
    {
      "description": "Caps Lock → Hyper Key (⌃⌥⇧⌘) (Caps Lock if alone)",
      "manipulators": [
        {
          "from": {
            "key_code": "caps_lock"
          },
          "to": [
            {
              "key_code": "left_shift",
              "modifiers": [
                "left_command",
                "left_control",
                "left_option"
              ]
            }
          ],
          "to_if_alone": [
            {
              "key_code": "caps_lock"
            }
          ],
          "type": "basic"
        }
      ]
    }
  ]
}

yabai窗口焦点切换

{
  "title": "yabai window focus",
  "rules": [
    {
      "description": "Hyper Key h/j/k/l",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "h",
            "modifiers": {
              "mandatory": [
                "left_shift",
                "left_command",
                "left_control",
                "left_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "shell_command": "/usr/local/bin/yabai -m window --focus west"
            }
          ]
        },{
          "type": "basic",
          "from": {
            "key_code": "l",
            "modifiers": {
              "mandatory": [
                "left_shift",
                "left_command",
                "left_control",
                "left_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "shell_command": "/usr/local/bin/yabai -m window --focus east"
            }
          ]
        },{
          "type": "basic",
          "from": {
            "key_code": "j",
            "modifiers": {
              "mandatory": [
                "left_shift",
                "left_command",
                "left_control",
                "left_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "shell_command": "/usr/local/bin/yabai -m window --focus south"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "k",
            "modifiers": {
              "mandatory": [
                "left_shift",
                "left_command",
                "left_control",
                "left_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "shell_command": "/usr/local/bin/yabai -m window --focus north"
            }
          ]
        }
      ]
    }
  ]
}


配置文件位置

nvim ~/.config/karabiner/karabiner.json

参考

https://www.163.com/dy/article/EP9PPA7S0531A225.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

鼠标macOS下定义快捷键(各品牌通用) 的相关文章

随机推荐