jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.08k stars 129 forks source link

Handling Conditional Alt Behavior in Kanata: Shortcuts in Custom Layer Without Alt, Unmapped Keys with Alt #1277

Closed sohanemon closed 1 month ago

sohanemon commented 1 month ago

Discussed in https://github.com/jtroo/kanata/discussions/1275

Originally posted by **sohanemon** October 8, 2024 I want to achieve some shortcuts using `Alt`, but `Alt` already has several default shortcuts. For these, I haven’t assigned any specific shortcut in my custom layer. Here’s the config I’ve tried: ```lisp inner-nav (layer-toggle inner-nav_layer) lalt (multi lalt (tap-hold-release 0 $ht lalt @inner-nav) ) ``` And here is the `inner-nav_layer`: ```lisp (deflayer inner-nav_layer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ M-tab _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ C-t C-l _ _ _ A-left C-pgdn C-pgup A-right _ _ _ _ _ C-w _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ) ``` Goal: - All the mentioned shortcuts should work **without adding `Alt`** to them. - Any unmapped keys (`_`) should behave as `Alt + key` (i.e., `Alt + q`, `Alt + anything` not defined in the layer). Also I've tried ```lisp inner-nav (layer-toggle inner-nav_layer) lalt (tap-hold-release 0 $ht lalt @inner-nav) ralt (tap-hold-release 0 $ht ralt @inner-nav) ``` This completely disables the `Alt` key for other shortcuts (e.g., `Alt + q` does not work). --- **How can I achieve the desired behavior where mapped shortcuts in the `inner-nav_layer` don’t include `Alt`, but unmapped keys trigger `Alt + key`?** Any suggestions would be much appreciated!
gerhard-h commented 1 month ago

pressing alt together with innernav innernav (multi lalt (layer-toggle inner-nav_layer)) will simplify the problem to just get rid of lalt where it is not needed. C-t becomes (multi lctl (unmod (lalt) t)) or (multi (unmod (lalt) lctl) (unmod (lalt) t)) not sure.

There is also a more complex route to solve this by assigning lalt to a virtual key (it was in one of the example .kbd files)

sohanemon commented 1 month ago

I do not understand the virtual key configs well. But i tried to unmod and send a key stroke with a specific modifier key like this (unmod C-t). I know I am wrong here. Can you suggest how can I reach my goal? I am newbie with kanata.

(deflayer inner-nav_layer
          _     _    _    _    _    _    _    _    _    _    _    _    _    _   _
          M-tab _    _    _    _    _    _    _    _    _    _    _    _    _   _
          _     (unmod C-t)   C-l  _    _    _    A-left C-pgdn C-pgup A-right  _    _    _
          _     _    C-w  _    A-v    _    _    _    _    _    _    _
          _     _    _         A-spc          _    _    _ 
          )
sohanemon commented 1 month ago

After trying a lot I find a solution with this:

(deflayer inner-nav_layer
          _     _    _    _    _    _    _    _    _    _    _    _    _    _   _
          M-tab _    _    _    _    _    _    _    _    _    _    _    _    _   _
          _     (unmod lctl t)  (unmod lctl l)  _    _    _    left C-pgdn C-pgup right  _    _    _
          _     _    (unmod lctl w)  _    _    _    _    _    _    _    _    _
          _     _    _         _          _    _    _ 
          )

But if i use (unmod lctl pgdn) its throwing error. What could be the mistake?

sohanemon commented 1 month ago

This issue is fixed. I found a workaround. but if you suggest any better approach that would be much appreciated