Skip to content

Instantly share code, notes, and snippets.

@ulic-youthlic
Created July 23, 2024 14:05
Show Gist options
  • Save ulic-youthlic/fb0213470ff9add23c64991053b604a3 to your computer and use it in GitHub Desktop.
Save ulic-youthlic/fb0213470ff9add23c64991053b604a3 to your computer and use it in GitHub Desktop.
Kanata configuration for mapping `Capslock`.
#|
Kanata
CapsLock tap to Esc
CapsLock hold to Ctrl
|#
(defcfg
process-unmapped-keys no
)
(defsrc
caps
)
(deflayer default
@cac
)
(defalias
cac (tap-hold 200 200 esc lctrl)
)
@ulic-youthlic
Copy link
Author

ulic-youthlic commented Jan 6, 2025

when i use, the pwsh tell me the

 x Error in configuration
      ,-[kanata.kbd:1408:1]
 1408 |
 1409 | ,-> (defcfg
 1410 | |       process-unmapped-keys no
 1411 | |-> )
      : `---- Error here
 1412 |
      `----
  help: Only one defcfg is allowed, found more. Delete the extras.

        For more info, see the configuration guide:
        https://github.com/jtroo/kanata/blob/main/docs/config.adoc

21:18:54.1943 [ERROR] failed to parse file

how to fix it, I'm a noob.

@Break-Unrestrained: i think you can just remove the (defcfg ...) expr. now proccess-unmapped-keys is disabled by default.

@ulic-youthlic
Copy link
Author

if it works, plz tell me, i'll update my gist.

@Break-Unrestrained
Copy link

#|
    Kanata

    CapsLock tap to Esc
    CapsLock hold to Ctrl
|#

;;  
(defcfg
    process-unmapped-keys no
)

;; default keyboard layout
(defsrc
    caps  ;; type → esc, hold caps → ctrl
    esc  ;; type esc → caps, hold esc → esc
)

;;
(deflayer default
    @cac
    @esc-behavior
)

;;
(defalias
    cac (tap-hold 190 190 esc lctrl)  ;; hold CapsLock → Esc, press CapsLock → LCtrl
    esc-behavior (tap-hold 190 190 caps esc)  ;; hold Esc → CapsLock, press Esc → Esc
)

This is based on your modifications, and there are no problems now. The previous issue was because I didn't delete the content in the default kanata file, which resulted in multiple defsrcs. (I use version 1.7.0). Thank for your help. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment