Karabiner-Elements|Keyboard Customizer for macOS

问题:2009年制Apple A1314键盘,经常有两三个数字键会随机自动连击,重複輸入。
打开键盘帽清洁后,没有修复。故应属电路板故障。
解决方案:①拦截数字键 ②按住fn后可输入数字键

下载并安装Karabiner-Elements
安装完成后,在Mac设置软件权限
确认 A1314 的设备 ID
Karabiner → Devices
・Vendor ID:1452
・Product ID:599
※ 注意是「外接键盘」的ID
用TextEdit制作规则文件
① 打开 TextEdit
Command + 空格:TextEdit
切换为纯文本模式(Shift + Command + T)
{
  "title": "A1314 (VID1452 PID599) Numbers require fn",
  "rules": [
    {
      "description": "A1314 only: 1-0, -, = work only while holding fn (otherwise disabled)",
      "manipulators": [
        {
          "type": "basic",
          "from": { "key_code": "fn", "modifiers": { "optional": ["any"] } },
          "to": [{ "set_variable": { "name": "a1314_fn_pressed", "value": 1 } }],
          "to_after_key_up": [{ "set_variable": { "name": "a1314_fn_pressed", "value": 0 } }],
          "conditions": [
            {
              "type": "device_if",
              "identifiers": [{ "vendor_id": 1452, "product_id": 599 }]
            }
          ]
        },

        // --- 1
        {
          "type": "basic",
          "from": { "key_code": "1" },
          "to": [{ "key_code": "1" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "1" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 2
        {
          "type": "basic",
          "from": { "key_code": "2" },
          "to": [{ "key_code": "2" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "2" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 3
        {
          "type": "basic",
          "from": { "key_code": "3" },
          "to": [{ "key_code": "3" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "3" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 4
        {
          "type": "basic",
          "from": { "key_code": "4" },
          "to": [{ "key_code": "4" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "4" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 5
        {
          "type": "basic",
          "from": { "key_code": "5" },
          "to": [{ "key_code": "5" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "5" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 6
        {
          "type": "basic",
          "from": { "key_code": "6" },
          "to": [{ "key_code": "6" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "6" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 7
        {
          "type": "basic",
          "from": { "key_code": "7" },
          "to": [{ "key_code": "7" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "7" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 8
        {
          "type": "basic",
          "from": { "key_code": "8" },
          "to": [{ "key_code": "8" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "8" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 9
        {
          "type": "basic",
          "from": { "key_code": "9" },
          "to": [{ "key_code": "9" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "9" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- 0
        {
          "type": "basic",
          "from": { "key_code": "0" },
          "to": [{ "key_code": "0" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "0" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- - (hyphen)
        {
          "type": "basic",
          "from": { "key_code": "hyphen" },
          "to": [{ "key_code": "hyphen" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "hyphen" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },

        // --- = (equal_sign)
        {
          "type": "basic",
          "from": { "key_code": "equal_sign" },
          "to": [{ "key_code": "equal_sign" }],
          "conditions": [
            { "type": "variable_if", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        },
        {
          "type": "basic",
          "from": { "key_code": "equal_sign" },
          "to": [{ "key_code": "vk_none" }],
          "conditions": [
            { "type": "variable_unless", "name": "a1314_fn_pressed", "value": 1 },
            { "type": "device_if", "identifiers": [{ "vendor_id": 1452, "product_id": 599 }] }
          ]
        }
      ]
    }
  ]
}
②复制粘贴以下代码
⭐️ 注意替换修改设备ID
・Vendor ID:1452(例)
・Product ID:599(例)
③文件 → 保存
文件名输入:
a1314_fn_numbers.json
位置选择:桌面
④把规则文件移动到 Karabiner 目录
打开 Finder
按:Shift + Command + G
输入:
~/.config/karabiner/assets/complex_modifications
把刚才保存在桌面的【a1314_fn_numbers.json】文件放进去
Karabiner启用规则
打开:
Karabiner → Complex Modifications → Add Rule
就能看到刚保存的规则了
点击 Enable
键盘设定完成
解决了数字键随机自动连击的问题。同时,需要时按fn键即可输入数字。