Closed santhoshr closed 3 months ago
Try (not (or a b c))
Random thought, perhaps or should have the alternate name "any", likewise and could have the alternate name "all"
I realized "not" works on "key press", any way to make it work on key release?
Random thought, perhaps or should have the alternate name "any", likewise and could have the alternate name "all"
any / all & or / and won't make much difference "all" could even cause confusion
I realized "not" works on "key press", any way to make it work on key release?
It's not clear to me exactly what you mean. My guess is you're looking for (on-release tap-vkey vk-switch)
where vk-switch
is defined to be the switch action you want.
With key-history I was able to achieve pseudo condition to implement kind-of quasimode (introduced by Jef Raskin).
Bit of explanation below, Quasimode keys works like shift, one key is held while typing other keys. So I want some of my keys to have this behaviour, one such functionality is Search, on pressing capslock and typing I want to search, and on release it should trigger enter or escape based on whether I typed or not, since we are working with keyboard we can't check application input box if it is empty or not to trigger enter or escape. Running the below code and opening a browser page, holding capslock will allow for kind-of quasimode search, and on release, it would trigger escape or return.
(defcfg
process-unmapped-keys yes
concurrent-tap-hold yes)
(defsrc
caps)
(deflayer default
@fin)
(defalias
fin (multi (on-press tap-vkey cf) (on-release tap-vkey fc)))
(defvirtualkeys
cf C-f
es esc
en ret
fc (switch
((key-history f 1)) esc break
((key-history ret 1)) esc break
() ret break)
no (switch
((key-history f 1)) esc break
((not a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 lsft rsft)) esc break
((key-history ret 1)) esc break
() ret break))
In the above,
fin (multi (on-press tap-vkey cf) (on-release tap-vkey no)))
), it will work but you have to "hold" one of the letters to get return, to test open notepad, hold search key, start typing now release it will trigger esc not return because switch case fails in "not" since none of the key in the list is on "pressed" state, I have included lsft and rshft in the list so if you type after holding search key now before release if you hold shift then it will trigger ret properly,
Requirements
Describe the bug
"not" operator doesn't work with list of keys, for e.g.
curiously not works with input real
((not (input real a))) S-a break
Is there a way to check previous key input? for e.g. to check if I have pressed any of given list of keys and they can be pressed individually or in combination, for e.g. if a-z letters are configured and when switch returns I can either press escape or press return based on switch evaluation? Key-history will not work because it will take single key and one should also give recency, if I'm typing any word then I cannot predict where 'a' comes also I need list of keys. Key-timing will not work because if I use switch for processing keys while holding some other key, if I hold alt key and use this logic key-timing will take alt key into account.
Relevant kanata config
No response
To Reproduce
Given as part of description
Expected behavior
"not" operator working
Kanata version
1.6.1
Debug logs
No response
Operating system
Windows 10
Additional context
No response