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

相关推荐
Geeker555 小时前
如何在忘记密码的情况下解锁Android手机?
android·网络·macos·华为·智能手机·电脑·手机
吞掉星星的鲸鱼8 小时前
mac显示隐藏的.git文件
macos
1024小神8 小时前
mac上使用finder时候,显示隐藏的文件或者文件夹
macos
顶顶年华正版软件官方8 小时前
Mac如何杀毒?Mac电脑如何杀毒 mac杀毒软件推荐 mac杀毒软件哪个好用
经验分享·macos·电脑·cleanmymacx激活码·mac杀毒软件哪个好·苹果电脑系统优化软件
<花开花落>8 小时前
iOS App 测试环境升级,遇到的问题以及解决方法
macos·ios·appium
cpluser8 小时前
在 VS Code 中自动化 Xcode 项目编译和调试
macos·ios·自动化·apple vision pro·xcode
鹿屿二向箔8 小时前
iOS开发-Xcode
macos·ios·xcode
Geeker5514 小时前
如何在忘记密码的情况下删除华为ID激活锁
android·运维·服务器·网络·macos·华为·智能手机
*橙子15 小时前
自用款 复制粘贴工具 Paste macOS电脑适配
macos
一个小浪吴啊16 小时前
Mac/Linux安装JMeter压测工具
linux·jmeter·macos