5

喜欢这个程序并感谢任何帮助

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

总结一下:

  1. 程序激活
  2. 大写锁定关闭时键盘处于默认状态
  3. 当大写锁定打开时,我可以使用 WASD 作为箭头键
  4. 一旦我按下大写锁定,按键将返回默认状态。

非常感谢你们为我提供的任何帮助。希望这已经得到解决并且很容易解决

4

3 回答 3

4

这对我有用:

{
    "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": []文件元素的括号内~/.config/karabiner/karabiner.json,或者在 中创建一个新的 JSON 文件~/.config/karabiner/assets/complex_modifications,将上面的代码包装在:

{
  "title": "WASD arrow Keys toggled by Capslock",
  "rules": [
    (insert code here)
  ]
}

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

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

请注意,此脚本替换了大写锁定的功能,这意味着:它用作箭头键切换器,而不是大写键切换器。

这是对来自Karabiner 站点的脚本“TouchCursor Mode”的修改,它在按下大写锁定时切换一个变量,然后根据该变量使用 WASD 作为键或箭头。与@user9680958 使用的技术类似。

于 2018-12-10T01:11:43.373 回答
2

Both solutions for caps lock mode and caps hold mode:

  • p.s. you can easily switch the script down below to "wasd" or "hjkl", etc.

1. Setup Karabiner:

  • Download Karabiner
  • When opening it requires to enable some stuff in the Settings (just follow the steps it requests from you)

Set up the Script:

  1. Create a JSON file on your desktop:

    • cmd + space to open the spotlight
    • type in terminal
    • type in cd
    • type in cd desktop
    • touch myscript.json
    • copy paste one of the codes down below in the new file
  2. Go back to the terminal

    • Type in cd
    • Type cd desktop
    • Type mv myscript.json ~/.config/karabiner/assets/complex_modifications
  3. Now open Karabiner Elements and go to "Complex modifications"

    • Press "add Rule"
    • Now there should be your custom rule to enable
    • Have fun.

Code 1 for Caps lock "to enter arrow key mode" and press again "to exit arrow key mode":

{
  "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"
            }
        ]
    }
  ]
}

Code 2 If you want to hold Caps while using the arrow Keys use this one instead:

{
  "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"
            }
        ]
    }
  ]
}
于 2020-09-17T10:08:44.647 回答
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
                            }
                        }
                    ]
                }

于 2018-04-22T07:43:31.223 回答