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無法識別;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章