目录

HHKB键盘修改上下左右建

概述

因为之前一直用 Poker 的 61 位键盘,最近老婆给我买了一个 HHKB,因为习惯了 Poker 的方向键组合,Fn + wasd 的组合键分别代表上下左右键,而 HHKB 默认的是 [ ; ’ / 作为组合的方向键,从使用上来说,从左手按方向键的习惯切换成右手会很难受,另外还包括像 ` 和 ~ 符号的使用,习惯了 Poker 的组合键,还真不适应新的方式了。于是就要研究一下,怎么修改 HHKB 的方向键组合键了,目标就是可以跟原来 Poker 的使用体验一致。

/hhkb%E9%94%AE%E7%9B%98%E4%BF%AE%E6%94%B9%E4%B8%8A%E4%B8%8B%E5%B7%A6%E5%8F%B3%E5%BB%BA/img_1.png

操作

需要下载 MacOS 版本的 Karabiner-Elements,找到 Complex Modifications,通过 Add rule 添加规则,下面是配置文件的具体位置和写法。

1
vim $HOME/.config/karabiner/assets/complex_modifications/mac.json

具体的配置文件如下。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
  "title": "hhkb wasd",
  "rules": [
    {
      "description": "right_option + w/a/s/d to arrows",
      "manipulators": [
        {
          "from": {
            "key_code": "w",
            "modifiers": {
              "mandatory": [
                "right_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "up_arrow"
            }
          ],
          "type": "basic"
        },
        {
          "from": {
            "key_code": "a",
            "modifiers": {
              "mandatory": [
                "right_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_arrow"
            }
          ],
          "type": "basic"
        },
        {
          "from": {
            "key_code": "s",
            "modifiers": {
              "mandatory": [
                "right_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "down_arrow"
            }
          ],
          "type": "basic"
        },
        {
          "from": {
            "key_code": "d",
            "modifiers": {
              "mandatory": [
                "right_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "right_arrow"
            }
          ],
          "type": "basic"
        }
      ]
    },
    {
      "description": "` to poker",
      "manipulators": [
        {
          "from": {
            "key_code": "escape",
            "modifiers": {
              "mandatory": [
                "right_option"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "grave_accent_and_tilde"
            }
          ],
          "type": "basic"
        }
      ]
    },
    {
      "description": "~ to poker",
      "manipulators": [
        {
          "from": {
            "key_code": "escape",
            "modifiers": {
              "mandatory": [
                "left_shift"
              ],
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "grave_accent_and_tilde",
              "modifiers": {
                "mandatory": [
                  "left_shift"
                ],
                "optional": [
                  "any"
                ]
              }
            }
          ],
          "type": "basic"
        }
      ]
    }
  ]
}

配置文件导入之后,就可以在页面上直接看到了,键位也重新配置好了。

/hhkb%E9%94%AE%E7%9B%98%E4%BF%AE%E6%94%B9%E4%B8%8A%E4%B8%8B%E5%B7%A6%E5%8F%B3%E5%BB%BA/img.png

总结

最后还是要感谢我的老婆,写码这么多年,一直都不舍得换 HHKB,靠着老婆,我也终于用上了,以后写码就更有动力了 :)