Combine Layers and Simlayers in Karabiner

Got a quick Karabiner question on twitter over the weekend:

Assuming a layer and simlayer like these:

:layers {;
:tab-mode {:key :tab}
;
}
:simlayers {;
:t-mode {:key :t}
;
}

I would approach combining them like so:

:main [
;order matters*
{:des "tab+t"
:rules [[:condi :tab-mode :t-mode]
[:h [:b :o :t :h]];
]}
{:des "t"
:rules [[:condi ["tab-mode" 0] :t-mode]
[:h [:t]];
]}
{:des "tab"
:rules [:tab-mode
[:h [:t :a :b]];
]}
;
]
;
}

:condi allows you to define multiple conditions that need to be met for the following rules. This is very helpful for combining simlayers with applications. [:condi :tab-mode :chrome] would allow you to define a set of rules specific to Chrome. Or a more complex example would be “Ableton rules when 2 fingers are on the trackpad”:

[:condi :ableton ["multitouch_extension_finger_count_total" 2]]
[:-r :loop_selection]
[:-s :split_clip]

*Order is important

You must press “tab”, then “t”, then “h”. But then as long as you’re holding down “tab” and “t”, you can slam down “h” as many times as you want. You could set up the reverse condition [:condi :t-mode :tab-mode], but then you’d need to press “t” then “tab”.

Full file:

{:default true
; Layers Are Typically "Thumb Keys" or "Pinky Keys"
:layers {;
:tab-mode {:key :tab}
;
}
:simlayers {;
:t-mode {:key :t}
;
}
:main [
;
{:des "t"
:rules [[:condi ["tab-mode" 0] :t-mode]
[:h [:t]];
]}
{:des "tab"
:rules [:tab-mode
[:h [:t :a :b]];
]}
{:des "tab+t"
:rules [[:condi :tab-mode :t-mode]
[:h [:b :o :t :h]];
]}
;
]
;
}

Get Automation Tips in Your Inbox

Sign-up to get Automation tips sent directly to your inbox to improve your daily computer life!

    No spam. Unsubscribe whenever.