to_if_canceled/to_if_invoked ignore modifiers if identical those in "to"
Author: eugenesvkCreated Nov 4, 2022Updated Sep 15, 2026
It seems that the to_if_canceled/to_if_invoked ignore the modifiers element of the key_code if it's the same modifier as the one in the from field
For example, the code below fails: if you press ⌘F and
- release it and wait, it types
rinstead of firing ⌘F (fromto_if_invoked) - release it and cancel (Esc), it types
ginstead of firing ⌘G (fromto_if_canceled)
{ "description":" LCmd+double tap F bug","manipulators":[
{ "type":"basic","conditions":[{"type":"variable_if","name":"left_command_f pressed","value":1}],
"from" :{"key_code":"f","modifiers":{"mandatory":["left_command"],"optional":["caps_lock"]}},
"to" :[{"shell_command":"open ''"}] },
{ "type":"basic","conditions":[],
"from" :{ "key_code":"f","modifiers":{"mandatory":["left_command"],"optional":["caps_lock"]}},
"to" :[
{ "set_variable" :{ "name":"left_command_f pressed","value":1}}],
"parameters":{"basic.to_delayed_action_delay_milliseconds":1000}, "to_delayed_action":{
"to_if_canceled":[{"set_variable":{"name":"left_command_f pressed","value":0}},
{"key_code":"g","modifiers":[ "left_command"]}],
"to_if_invoked" :[{"set_variable":{"name":"left_command_f pressed","value":0}},
{"key_code":"r","modifiers":[ "left_command"]}] } }
]},However, the same example works correctly if I change the modifier left_command that matches from to a non-matching alternative right_command
{ "description":" LCmd+double tap F bug workaround","manipulators":[
{ "type":"basic","conditions":[{"type":"variable_if","name":"left_command_f pressed","value":1}],
"from" :{"key_code":"f","modifiers":{"mandatory":["left_command"],"optional":["caps_lock"]}},
"to" :[{"shell_command":"open ''"}] },
{ "type":"basic","conditions":[],
"from" :{ "key_code":"f","modifiers":{"mandatory":["left_command"],"optional":["caps_lock"]}},
"to" :[
{ "set_variable" :{ "name":"left_command_f pressed","value":1}}],
"parameters":{"basic.to_delayed_action_delay_milliseconds":1000}, "to_delayed_action":{
"to_if_canceled":[{"set_variable":{"name":"left_command_f pressed","value":0}},
{"key_code":"g","modifiers":[ "right_command"]}],
"to_if_invoked" :[{"set_variable":{"name":"left_command_f pressed","value":0}},
{"key_code":"r","modifiers":[ "right_command"]}] } }
]},credits to https://github.com/pqrs-org/Karabiner-Elements/issues/2677#issuecomment-1107459534 for the workaround
this is tested on KE 13.7.0, sorry if I missed the fix in the later versions
Source: pqrs-org/Karabiner-Elements