yqrashawn / GokuRakuJoudo

config karabiner with ease
GNU General Public License v3.0
1.16k stars 121 forks source link

How do I toggle a layer back with the same keybinding ? #105

Closed tintinthong closed 3 years ago

tintinthong commented 3 years ago

I have found that using key chords to raise and lower layers are better with a single press (as opposed to held) if I don't want to pollute my current keybindings.

How can I enter and exit a layer using the same key chord?

I want to press

        {
         :des "Custom layers - toggle by single press only"
         :rules [
                 [[:j :i] ["symbol-layer" 1]]
                 [[:e :f] ["symbol-layer" 0]] ; I really just want this to be [:j :i]
                 [[:f :j] ["vi-mode" 0]]
                 ]
         }
        {:des "replacing numbers and symbols "
         :rules [
                 :symbol-layer
                 [:##h :0]
                 [:##u :1]
                 [:##i :2]
                 [:##o :3]
                 [:##p :4]
                 [:##open_bracket :4]
                 [:##j :5]
                 [:##k :6]
                 [:##l :7]
                 [:##semicolon :8]
                 [:##quote :9]
                 [:##a :!S1]
                 [:##s :!S2]
                 [:##d :!S3]
                 [:##f :!S4]
                 [:##g :!S5]
                 [:##w :!S6]
                 [:##e :!S7]
                 [:##r :!S8]
                 [:##q :!Sgrave_accent_and_tilde]
                 [:##v :grave_accent_and_tilde]
                 ]
         }
chrismo commented 3 years ago

This looks like this works, the order is essential. Thanks for posting your issue, it turns out I wanted the same thing but I'm brand new to the .edn format so your sample helped get me started.

{{:des   "Custom layers - toggle by single press only"
  :rules [[[:j :i] ["symbol-layer" 0] :symbol-layer]
          [[:j :i] ["symbol-layer" 1]]]}}

My editor is saying there's an error on that formatter ... so ... hopefully that's close enough.

tintinthong commented 3 years ago

This looks like this works, the order is essential. Thanks for posting your issue, it turns out I wanted the same thing but I'm brand new to the .edn format so your sample helped get me started.

{{:des   "Custom layers - toggle by single press only"
  :rules [[[:j :i] ["symbol-layer" 0] :symbol-layer]
          [[:j :i] ["symbol-layer" 1]]]}}

My editor is saying there's an error on that formatter ... so ... hopefully that's close enough.

Cheers @chrismo ! it works for me. : )