美文网首页
macOS修改方向键

macOS修改方向键

作者: 梨花菜 | 来源:发表于2020-06-09 19:57 被阅读0次

1.下载改键器Karabiner-Elements

2.功能说明

配置文件说明:
CapsLock指的是切换大小写的CapsLock按键,一般都是在A键的左边第一个

2.1方向键组合

  • 左=CapsLock+j
  • 右=CapsLock+l
  • 上=CapsLock+i
  • 下=CapsLock+k

2.2功能键组合

  • 退格键=CapsLock+h
  • end=CapsLock+e
  • home=CapsLock+m
  • page_up=CapsLock+u
  • page_down=CapsLock+d

3.新增自定义配置

  • 进入配置文件的路径:cd ~/.config/karabiner/assets/complex_modifications/
  • 使用vi新建一个配置文件:vi CapsLock.json
    完整的配置文件路径和文件名~/.config/karabiner/assets/complex_modifications/CapsLock.json

配置文件内容:

{
  "title": "Use CAPS LOCK for vi navigation",
  "rules": [
    {
      "description": "CAPS LOCK + jkli to arrow keys",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "j",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "k",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "down_arrow"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "i",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "up_arrow"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "l",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "h",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "delete_or_backspace"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "m",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "home"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "e",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "end"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "u",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "page_up"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "d",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "page_down"
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "caps_lock pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "caps_lock",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "set_variable": {
                "name": "caps_lock pressed",
                "value": 1
              }
            }
          ],
          "to_after_key_up": [
            {
              "set_variable": {
                "name": "caps_lock pressed",
                "value": 0
              }
            }
          ]
        }
      ]
    }
  ]
}

4.启用自定义的配置

image.png
image.png image.png

相关文章

网友评论

      本文标题:macOS修改方向键

      本文链接:https://www.haomeiwen.com/subject/gometktx.html