karabiner json语法

karabiner json语法

to_if_alone

如果同时制定了to,
那么to对应的key必须是非可见字符,例如control,shift或者command,
为什么呢? If to events are specified, to events are released before to_if_alone are posted. 如果制定了"to" event,那么先触发"to" event,后触发to_if_alone event, 例如

{
      "description": "14. ",
      "manipulators": [
        {
          "from": {
            "key_code": "u",
            "modifiers": {
            }
          },
          "to": [
            {
              "key_code": "h"

            }
          ],
          "to_if_alone": [
            {
              "key_code": "g"
            }
          ],
          "type": "basic"
        }
      ]
    }

输入u时,会输入两个字符"hg", 但是按下u,不松开,同时按下a,那么输入"ha" < from>+a =>ha

< from>单独按下 =>hg

to_if_held_down

用法 参考:https://pqrs.org/osx/karabiner/json.html#to-if-held-down

双击right_option,触发left_shift+10

{
      "description": "12. Post option_L+T(svn update) right_option x2(双击);post left_shift+10(IDEA run) when is pressed alone",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "right_option",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "t",
              "modifiers": [
                "left_control"
              ]
            }
          ],
          "conditions": [
            {
              "type": "variable_if",
              "name": "right_option pressed",
              "value": 1
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "right_option",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "parameters": {
            "basic.to_delayed_action_delay_milliseconds": 1000
          },
          "to": [
            {
              "set_variable": {
                "name": "right_option pressed",
                "value": 1
              }
            },
            {
              "key_code": "right_option"
            }
          ],
          "to_delayed_action": {
            "to_if_invoked": [
              {
                "set_variable": {
                  "name": "right_option pressed",
                  "value": 0
                }
              },
              {
                "key_code": "f10",
                "modifiers": [
                  "left_shift"
                ]
              }
            ],
            "to_if_canceled": [
              {
                "set_variable": {
                  "name": "right_option pressed",
                  "value": 0
                }
              }
            ]
          }
        }
      ]
    }

注意事项

json文件中不能有注释,否则 karabiner element无法识别;

转载于:https://my.oschina.net/huangweiindex/blog/2246247

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值