macOS使用Karabiner-Elements解决罗技鼠标G304连击、单击变双击的故障

记录一下罗技鼠标G304单击变双击的软件解决过程和方案(适用于macOS, 如果是Windows,使用AutoHotKey也有类似解决办法、方案,改日提供):

背景:通过罗技Logitech G HUB软件对罗技的游戏鼠标侧键button4做了映射,映射到了command+w,用于快速关闭窗口或标签,但此侧健使用2年后出现了鼠标按键连击现象,单击变双击,经常连续关闭2个标签页。可以通过罗技售后维修,但由于已经过保,通过研究找到了软件的解决办法:

首先通过罗技Logitech G HUB软件,通过该软件把该鼠标设定到on-board模式(软件模式下Karabiner-Elements跟踪不到button4按键)

然后通过Karabiner-Elements对侧键进行修改,首先要在Devices栏确保对此鼠标有做监控和跟踪Modify events:

然后转到Misc, 打开配置文件夹,并编辑配置文件karabiner.json:

直接通过代码对karabiner.json添加以下规则:

javascript 复制代码
{
    "description": "button4 twice",
    "manipulators": [
        {
            "conditions": [
                {
                    "name": "press_button4",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "pointing_button": "button4"
            },
            "to": [
                {
                    "key_code": "w",
                    "modifiers": [
                        "left_command"
                    ]
                }
            ],
            "type": "basic"
        },
        {
            "from": {
                "pointing_button": "button4"
            },
            "parameters": {
                "basic.to_delayed_action_delay_milliseconds": 100
            },
            "to": [
                {
                    "set_variable": {
                        "name": "press_button4",
                        "value": 1
                    }
                }
            ],
            "to_delayed_action": {
                "to_if_canceled": [
                    {
                        "set_variable": {
                            "name": "press_button4",
                            "value": 0
                        }
                    }
                ],
                "to_if_invoked": [
                    {
                        "set_variable": {
                            "name": "press_button4",
                            "value": 0
                        }
                    },
                    {
                        "key_code": "w",
                        "modifiers": [
                            "left_command"
                        ]
                    } 
                ]
            },
            "type": "basic"
        }
    ]
}

代码中to_delayed_action_delay_milliseconds 指定了双击判定的毫秒间隔,设置为100毫秒,100毫秒内的双击将视同单击。 此值可自由设定。 若100毫秒内无双击,则继续执行原单击to_if_invoked。

至此,问题搞定。

官方参考文档:

to_delayed_action | Karabiner-Elements

Karabiner-Elements是一个很强大的专门用于修改macOS按键映射的开源免费软件:

Karabiner-Elements官网链接:

Karabiner-Elements

相关推荐
William.csj5 小时前
Mac——文件夹压缩的简便方法
macos
北冥有鱼被烹5 小时前
【问题】Mac 的 Finder 中没有桌面选项如何处理?(访达 -> 设置 -> 边栏 -> 勾选桌面)
macos
wenxiaocsdn8 小时前
macos虚拟机-演示篇三配置clover引导
macos
迷路爸爸18010 小时前
源码编译安装最新 tmux 教程(含 Debian/Ubuntu/CentOS/Arch/macOS 等系统)
linux·ubuntu·macos·centos·debian·tmux·archlinux
xingxing_F10 小时前
Rhino 8 for Mac 犀牛3D建模软件
macos·3d
takashi_void21 小时前
如何在本地部署大语言模型(Windows,Mac,Linux)三系统教程
linux·人工智能·windows·macos·语言模型·nlp
哦豁灬1 天前
macOS 常用快捷键
macos
亚林瓜子1 天前
在vscode中全选后,同时在每行行尾,开始多行编辑(Mac版)
ide·vscode·macos
一张假钞1 天前
Mac OS 常用快捷键
macos
2501_915921431 天前
iOS混淆与IPA加固实战手记,如何构建苹果应用防反编译体系
android·macos·ios·小程序·uni-app·cocoa·iphone