使用Karabiner Elements,如何将WASD键切换为箭头键。只有当Caps Lock激活时?

时间:2018-02-21 04:41:06

标签: elements karabiner

喜欢这个节目并感谢任何帮助

与标题状态一样,我的左手一直放在我的SHIFT KEY,OPTION KEY和COMMAND键上。但我讨厌当我必须使用我的箭头键移动形状。我希望能够将WASD更改为箭头键以轻推形状。这也允许小指点击左侧的SHIFT KEY,这样我就可以一次移动10px的形状。但是,我希望能够通过按下Caps lock并按住它直到我释放来切换到箭头功能。这样做可以让我在构建/ UI时更多地使用热键。

总结:

  1. 程序有效
  2. 当大写锁定关闭时,
  3. 键盘处于默认状态
  4. 当Caps lock打开时,我可以使用WASD作为箭头键
  5. 一旦我点击大写锁定,按键将返回默认状态。
  6. 非常感谢你们帮助我们的任何帮助。希望这已经解决并且很容易解决

3 个答案:

答案 0 :(得分:1)

这对我有用:

{
    "description": "WASD arrow Keys toggled by Capslock",
    "manipulators": [
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_unless",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "set_variable": {
                        "name": "wasd_arrow_keys_mode",
                        "value": 1
                    }
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "caps_lock",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "set_variable": {
                        "name": "wasd_arrow_keys_mode",
                        "value":  0
                    }
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "a",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "left_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "s",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "down_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "w",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "up_arrow"
                }
            ],
            "type": "basic"
        },
        {
            "conditions": [
                {
                    "name": "wasd_arrow_keys_mode",
                    "type": "variable_if",
                    "value": 1
                }
            ],
            "from": {
                "key_code": "d",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "right_arrow"
                }
            ],
            "type": "basic"
        }
    ]
}

您可以将代码放在文件"rules": []的{​​{1}}元素的括号内,也可以在~/.config/karabiner/karabiner.json中创建一个新的JSON文件,并将上面的代码包装在以下内容中:

~/.config/karabiner/assets/complex_modifications

如果您选择单独的JSON文件,则一旦保存,就可以通过“复杂修改”>“添加规则”通过Karabiner-Elements UI启用它。

我正在使用Karabiner beta 12.1.56,但它应该可以在Karabiner稳定版上使用。

请注意,此脚本取代了大写锁定功能,即:它用作箭头键切换器,而不是大写键切换器。

这是对Karabiner site脚本“ TouchCursor Mode”的修改,该脚本在按下Capslock时切换变量,然后根据该变量将WASD用作键或箭头。与@ user9680958使用的技术类似。

答案 1 :(得分:0)



{
                    "type": "basic",
                    "description": "",
                    "from": {
                        "key_code": "w",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "up_arrow"
                
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "caps_lock pressed",
                            "value": 1
                        }
                    ]
                },
{
                    "type": "basic",
                    "description": "",
                    "from": {
                        "key_code": "s",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "down_arrow"
                
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "caps_lock pressed",
                            "value": 1
                        }
                    ]
                },
{
                    "type": "basic",
                    "description": "",
                    "from": {
                        "key_code": "a",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "left_arrow"
                
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "caps_lock pressed",
                            "value": 1
                        }
                    ]
                },
{
                    "type": "basic",
                    "description": "",
                    "from": {
                        "key_code": "d",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "right_arrow"
                
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "caps_lock pressed",
                            "value": 1
                        }
                    ]
                },
               {
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                
                    "to": [
                        {
                            "key_code": "caps_lock"
                        },
                    
                        {
                            "set_variable": {
                                "name": "caps_lock pressed",
                                "value": 0
                            }
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "caps_lock pressed",
                            "value": 1
                        }
                    ]
                
                },

                {
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },

                    "to": [
                        {
                            "key_code": "caps_lock"
                        }
                    ],
                    "to_if_alone": [
                        {
                            "set_variable": {
                                "name": "caps_lock pressed",
                                "value": 1
                            }
                        }
                    ]
                }




答案 2 :(得分:0)

大写锁定模式和大写保持模式的两种解决方案:

  • p.s。您可以轻松地将下面的脚本切换为“ wasd”或“ hjkl”等。

1。设置Karabiner:

  • 下载Karabiner
  • 打开时,需要启用“设置”中的某些内容(只需按照其要求的步骤进行操作)

设置脚本:

  1. 在桌面上创建JSON文件:

    • cmd +打开聚光灯的空间
    • 输入终端
    • 输入cd
    • 在CD桌面中输入
    • 触摸myscript.json
    • 将以下代码之一复制粘贴到新文件中
  2. 返回终端

    • 输入cd
    • 键入cd桌面
    • 输入mv myscript.json〜/ .config / karabiner / assets / complex_modifications
  3. 现在打开Karabiner Elements并转到“复杂修改”

    • 按“添加规则”
    • 现在应该有您要启用的自定义规则
    • 玩得开心。

大写锁定的代码1“进入箭头键模式”,然后再次按“退出箭头键模式”:

{
  "title": "ijkl arrow Keys toggled by Capslock",
  "rules": [
    {
        "description": "ijkl arrow Keys toggled by Capslock",
        "manipulators": [
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_unless",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "caps_lock",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "set_variable": {
                            "name": "wasd_arrow_keys_mode",
                            "value": 1
                        }
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "caps_lock",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "set_variable": {
                            "name": "wasd_arrow_keys_mode",
                            "value":  0
                        }
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "j",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "left_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "k",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "down_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "i",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "up_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "l",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "right_arrow"
                    }
                ],
                "type": "basic"
            }
        ]
    }
  ]
}

代码2如果要在使用箭头键时按住Caps,请改用此键:

{
  "title": "ijkl arrow Keys toggled by Capslock",
  "rules": [
    {
        "description": "ijkl arrow Keys toggled by Capslock",
        "manipulators": [
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_unless",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "caps_lock",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "set_variable": {
                            "name": "wasd_arrow_keys_mode",
                            "value": 1
                        }
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "caps_lock",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "set_variable": {
                            "name": "wasd_arrow_keys_mode",
                            "value":  0
                        }
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "j",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "left_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "k",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "down_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "i",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "up_arrow"
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "name": "wasd_arrow_keys_mode",
                        "type": "variable_if",
                        "value": 1
                    }
                ],
                "from": {
                    "key_code": "l",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "right_arrow"
                    }
                ],
                "type": "basic"
            }
        ]
    }
  ]
}