#2115·kanata

Bug: Unexpected keycode is pressed in kanata but not in Windows. Clearing kanata states

Author: ErwynCreated Jul 20, 2026Updated Sep 15, 2026
Labelsbugquestionwindowsllhook

Requirements

Describe the bug

Since update to v1.12.0 I keep getting those errors when pressing standard keys like "E" or "R". I’m not sure to understand what the rule for triggering the issue is.

Image

Relevant kanata config

My config hasn’t changed, it is mainly the Arsenik on an Ergo-L layout config plus 1 or 2 changes:


;;==========================================================================;;
;;                                                                          ;;
;;  With Arsenik, choose the features you want for your keyboard:           ;;
;;  angle mods, Vim-like navigation layer, Mac/Azerty/Qwertz support, etc.  ;;
;;                                                                          ;;
;;==========================================================================;;

;; Every section is mandatory and should enable one and only one `include`
;; - enable each feature by un-commenting the related line.
;; - a commented line starts with ;;

;; Live-reload the configuration with Space+Backspace (requires layer-taps).

;; Timing variables for tap-hold effects.
(defvar
  ;; The key must be pressed twice in 200ms to enable repetitions.
  tap_timeout 200
  ;; The key must be held 200ms to become a layer shift.
  hold_timeout 200
  ;; Slightly higher value for typing keys, to prevent unexpected hold effect.
  long_hold_timeout 300
)

;;-----------------------------------------------------------------------------
;; Original key arrangement on your keyboard: Mac or PC.
;; Choose here if you want to add an angle mod: ZXCVB are shifted to the left.
;; See https://colemakmods.github.io/ergonomic-mods/angle.html for more details.

;; (include defsrc/pc.kbd)  ;; PC, standard finger assignment

;; --------------- Import ---------------
;; `defsrc` defines the keys that will be intercepted by kanata.

(defsrc
  1    2    3    4    5  bspc   6    7    8    9    0
  q    w    e    r    t         y    u    i    o    p
  a    s    d    f    g         h    j    k    l    ;
  z    x    c    v    b    <    n    m    ,    .    /
            lalt          spc             ralt
)
;; --------------------------------------

;; (include defsrc/mac.kbd)  ;; Mac, standard finger assignment
;; (include defsrc/pc_anglemod.kbd)  ;; PC, ZXCVB are shifted to the left
;; (include defsrc/mac_anglemod.kbd)  ;; Mac, ZXCVB are shifted to the left
;; (include defsrc/pc_wide_anglemod.kbd)  ;; PC, angle-mod + right hand shifted by one key
;; (include defsrc/mac_wide_anglemod.kbd)  ;; Mac, angle-mod + right hand shifted by one key


;;-----------------------------------------------------------------------------
;; `Base` layer: standard or dual keys? (layer-taps, homerow mods?)
;; If you just want angle mod, you still have to enable the standard base.

;; (include deflayer/base.kbd)  ;; standard keyboard behavior
;; (include deflayer/base_lt.kbd)  ;; layer-taps on both thumb keys
;; (include deflayer/base_lt_hrm.kbd)  ;; layer-taps + home-row mods

;; --------------- Import ---------------
;; Base layer: layer-taps under the thumbs + home-row mods on SDF and JKL

(deflayer base
  _    _    _    _    _    _    _    _    _    _    _
  q    w    e    r    t         y    u    i    o    p
  a    @ss  @dd  @ff  g         h    @jj  @kk  @ll  ;
  z    x    c    v    b    <    n    m    ,    .    /
            @sft          @nav            @sym
)

;; Timing variables are defined in `kanata.kbd` file.

(defalias
  ;; Main mod-tap: Nav layer when held, Space when tapped.
  nav (tap-hold $tap_timeout $hold_timeout spc (layer-while-held navigation))

  ;; Space-cadet thumb keys: Shift/BackSpace, AltGr/Enter.
  ;; Acts as a modifier by default, or as BackSpace/Enter when tapped separately.
  sft (tap-hold-press $tap_timeout $hold_timeout bspc lsft)
  sym (tap-hold-press $tap_timeout $hold_timeout ret (layer-while-held symbols))

  ;; Home-row mods
  ss (tap-hold $tap_timeout $long_hold_timeout s lmet)
  dd (tap-hold $tap_timeout $long_hold_timeout d lctl)
  ff (tap-hold $tap_timeout $long_hold_timeout f lalt)
  jj (tap-hold $tap_timeout $long_hold_timeout j lalt)
  kk (tap-hold $tap_timeout $long_hold_timeout k rctl)
  ll (tap-hold $tap_timeout $long_hold_timeout l lmet)
)
;; --------------------------------------

;; Note: not enabling layer-taps here makes the rest of the file useless.


;;-----------------------------------------------------------------------------
;; `Symbols` layer

;; (include deflayer/symbols_noop.kbd)  ;; AltGr stays as-is
;; (include deflayer/symbols_lafayette.kbd)  ;; AltGr programmation layer like Ergo‑L
;; (include deflayer/symbols_noop_num.kbd)  ;; AltGr stays as-is + NumRow layers

;; --------------- Import ---------------
;; Symbol layer: same as AltGr but enables a NumRow.
;; Concretely this does nothing, just let AltGr as-is for keyboard layouts
;; depending heavily on AltGr, like Bépo or simply Lafayette layouts like
;; Ergo‑L, which already have that layer baked in.
;; Except it adds an NumRow layer.

(deflayer symbols
  AG-1 AG-2 AG-3 AG-4 AG-5  XX  AG-6 AG-7 AG-8 AG-9 AG-0
  AG-q AG-w AG-e AG-r AG-t      AG-y AG-u AG-i AG-o AG-p
  AG-a AG-s AG-d AG-f AG-g      AG-h AG-j AG-k AG-l AG-;
  AG-z AG-x AG-c AG-v AG-b AG-< AG-n AG-m AG-, AG-. AG-/
            @num          AG-spc          _
)

;; Numrow layer

(deflayer numrow
  _    _    _    _    _     _   _    _    _    _    _
  @s1  @s2  @s3  @s4  @s5       @s6  @s7  @s8  @s9  @s0
  @1   @2   @3   @4   @5        @6   @7   @8   @9   @0
  @dk1 @dk2 @dk3 @dk4 @dk5  _   XX   @-   @,   @.   @/
            _              @nbs           @sym
)

(defalias
  num (layer-toggle numrow)
)
;; --------------------------------------

;; (include deflayer/symbols_lafayette_num.kbd)  ;; AltGr prog layer + NumRow layers

;; `Navigation` layer: ESDF or HJKL?

;; (include deflayer/navigation.kbd)  ;; ESDF on the left, NumPad on the right
;; (include deflayer/navigation_vim.kbd)  ;; HJKL + NumPad on [Space]+[Q]

;; --------------- Import ---------------
;; Vim-Navigation layer:
;;  - right: Vim-like arrows on HJKL, home/end page up/down, mouse scroll
;;  - left: one-hand shortcuts (Cmd/Ctrl-WASZXCV), Tab/Shift-Tab, prev/next
;;  - top: Super-num (i3/sway) or Alt-num (browser), zoom in/out

;; The `lrld` action stands for "live reload". This will re-parse everything
;; except for linux-dev, i.e. you cannot live reload and switch keyboard devices.

(deflayer navigation
  M-1  M-2  M-3  M-4  M-5  lrld M-6  M-7  M-8  M-9  M-0
  @pad @cls bck  fwd  XX        home pgup pgdn end  @run
  @all @sav S-tab tab `         lft  up   down rght @fun
  @ndo @cut @cpy @pst lctl  _   @mwl @mwu @mwd @mwr XX
            del             _             esc
)

;; NumPad
(deflayer numpad
  _    _    _    _    _     _   _    _    _    _    _
  XX   home up   end  pgup      @/   @7   @8   @9   XX
  XX   lft  down rght pgdn      @-   @4   @5   @6   @0
  XX   XX   XX   XX   XX    _   @,   @1   @2   @3   @.
            @std           @nbs           @std
)

;; function keys
(deflayer funpad
  XX   XX   XX   XX   XX   XX   XX   XX   XX   XX   XX
  f1   f2   f3   f4   XX        XX   XX   XX   XX   XX
  f5   f6   f7   f8   XX        XX   lalt lctl lmet _
  f9   f10  f11  f12  XX   XX   XX   XX   XX   XX   XX
            @std            _             @std
)

(defalias
  std (layer-switch base)

  ;; pad (layer-switch numpad)
  ;; fun (layer-while-held funpad)

  pad (tap-hold-press 0 $long_hold_timeout (layer-switch numpad) (layer-while-held numpad))
  fun (tap-hold-press 0 $long_hold_timeout (layer-switch funpad) (layer-while-held funpad))

  ;; Mouse wheel emulation
  mwu (mwheel-up    50 120)
  mwd (mwheel-down  50 120)
  mwl (mwheel-left  50 120)
  mwr (mwheel-right 50 120)
)
;; --------------------------------------

;; Replace XX by the keyboard shortcut of your application launcher, if any.
;; Mapped on [Space]+[P] in both navigation layers.

;; (defalias run M-p)  ;; [Command]-[P]
(defalias run XX)  ;; do nothing


;;-----------------------------------------------------------------------------
;; Aliases for `Symbols` and `Navigation` layers
;; Depends on PC/Mac and keyboard layout

;;(include defalias/ergol_pc.kbd)  ;; Ergo‑L PC

;; --------------- Import ---------------
;; Ergo‑L Windows/Linux aliases

;; Navigation layer
(defalias

  all C-a
  sav C-s
  cls C-t
  ndo C-z
  cut C-x
  cpy C-w
  pst C-v

  0 0
  1 1
  2 2
  3 3
  4 4
  5 5
  6 6
  7 7
  8 8
  9 9
  , .
  . n
)

;; Symbols layer
(defalias

  ^  AG-q
  <  AG-w
  >  AG-e
  $  AG-r
  %  AG-t
  @  AG-y
  &  AG-u
  *  AG-i
  '  AG-o
  `  AG-p

  {  AG-a
  pl AG-s
  pr AG-d
  }  AG-f
  =  AG-g
  \  AG-h
  +  AG-j
  -  AG-k
  /  AG-l
  '' AG-;

  ~  AG-z
  [  AG-x
  ]  AG-c
  _  AG-v
  #  AG-b
  |  AG-n
  !  AG-m
  ;  AG-,
  :  AG-.
  ?  AG-/
)

;; NumRow layer
(defalias

  s0 S-0
  s1 S-1
  s2 S-2
  s3 S-3
  s4 S-4
  s5 S-5
  s6 S-6
  s7 S-7
  s8 S-8
  s9 S-9
  nbs S-spc ;; narrow no-break space

  1dk o
  ;; digits must be escaped, otherwise they’re interpreted as delays in ms
  dk1 (macro @1dk @1)
  dk2 (macro @1dk @2)
  dk3 (macro @1dk @3)
  dk4 (macro @1dk @4)
  dk5 (macro @1dk @5)
)
;; --------------------------------------

;; (include defalias/qwerty-lafayette_pc.kbd)  ;; Qwerty‑Lafayette PC
;; (include defalias/qwerty_pc.kbd)  ;; Qwerty / Colemak PC
;; (include defalias/qwerty_mac.kbd)  ;; Qwerty / Colemak Mac
;; (include defalias/azerty_pc.kbd)  ;; Azerty PC
;; (include defalias/qwertz_pc.kbd)  ;; Qwertz PC
;; (include defalias/bepo_pc.kbd)  ;; Bépo PC
;; (include defalias/optimot_pc.kbd)  ;; Optimot PC

;; vim: set ft=lisp

To Reproduce

Just pressing keys like E or R or P on a Ergo-L layout

Expected behavior

I expect the keys to appear on screen and not have an error.

Kanata version

1.12.0

Debug logs

13:15:37.5182 [DEBUG] (1) kanata_state_machine::oskbd::windows::llhook: converting 19
13:15:37.5186 [DEBUG] (1) kanata_state_machine::kanata::windows::llhook: event loop: KeyEvent { code: KEY_R (82), value: Press }
13:15:37.5189 [DEBUG] (2) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_R (82), value: Press }
13:15:37.5254 [DEBUG] (2) kanata_state_machine::kanata::windows::llhook: synchronizing kanata keystates with windows
13:15:37.5257 [ERROR] Unexpected keycode is pressed in kanata but not in Windows. Clearing kanata states: R
13:15:37.6606 [DEBUG] (1) kanata_state_machine::oskbd::windows::llhook: converting 19
13:15:37.6609 [DEBUG] (1) kanata_state_machine::kanata::windows::llhook: event loop: KeyEvent { code: KEY_R (82), value: Release }
13:15:37.6611 [DEBUG] (1) kanata_state_machine::kanata::windows::llhook: forwarding release of never-seen press KeyEvent { code: KEY_R (82), value: Release }

Operating system and I/O mechanism

Windows 11 WinIOv2

Additional context

Re-installed version 1.11.0 and it does not trigger this error anymore so it seems tied to the latest release.