允许双击键按钮在不放开按住的情况下输出唯一的键盘组合

作者: eugenesvk创建于 2023年3月19日更新于 2026年9月16日

I'd like to do the following remapping:

  1. (single tap) ; to ; but only after a delay (to allow for a double tap/hold to have a different functionality), so this sets tap︔ variable to 1
  2. (single tap+X) ;x(any key≠;) to ;x (no change in behavior here), this resets tap︔ back to 0
  3. (double tap) ;; to : (replace semicolon with colon on double tap), this works by making ; with tap︔=1 condition output ⇧; and reset tap︔ back to 0
  4. (hold) ; to enter a new mode via setting hold︔ variable to 1 (and resetting it back to 0 on release) And it seems to me that it's currently impossible since same-key tap is treated as cancelled and same-key hold is reated as invoked, so there is no place for me to put ; output that would not break either double tap (and output :; instead of :) or hold (and output ; on hold) I'm using the following complex-modifications features
  • to_if_held_down sets hold︔ to 1
  • to_after_key_up resets the hold︔ back to 0, works fine
  • to_if_alone sets varSemicolonTap variable to 1 (or regular to woks)
  • to_delayed_action is where the main issue is, I need it to reset varSemicolonTap back to 0 after some delay, but also print the actual ;
    • to_if_canceled this helps with rule 2 as any x≠; in treated as cancellation, so if I output ; here it's inserted before x just fine. However it's also triggered when I tap ; again, and this is the buggy part. I don't
    • to_if_invoked works fine with printing ; after a delay but then holding the key is also treated as key being invoked, so on hold I get an extra ; I don't need Not sure what the best resolution is but maybe Either to_if_canceled could be optionally split into 2 conditions:
  • to_if_canceled_by_self
  • to_if_canceled_by_other

Or to_if_invoked could be optionally split into 2 conditions:

  • to_if_invoked_unless_hold
  • to_if_invoked_hold

Then I could skip printing ; on double tap in the cancelled clause, only reserving it for ;x Or I could print ; only at the to_if_invoked_unless_hold call while my hold will work by just changing the variables, but not printing anything

内容来源: pqrs-org/Karabiner-Elements