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无法识别;