Skip to content

Kitty keyboard: report CapsLock/NumLock state in modifier field #5789

@anthonykim1

Description

@anthonykim1

Follow-up to #5787.

The Kitty keyboard protocol spec requires lock state to be reported in the modifier bits:

shift 0b1 (1), alt 0b10 (2), ctrl 0b100 (4), super 0b1000 (8), hyper 0b10000 (16), meta 0b100000 (32), caps_lock 0b1000000 (64), num_lock 0b10000000 (128)

"if the key is pressed or the lock (for Caps Lock / Num Lock) is enabled, the key event must have the bit for that modifier set."

Currently _encodeModifiers() in src/common/input/KittyKeyboard.ts only reads shiftKey/altKey/ctrlKey/metaKey, so the lock bits are never set.

Kitty reference: key_encoding.c only strips lock bits in pure legacy mode (if (!key_encoding_flags) mods &= ~GLFW_LOCK_MASK); with any protocol flag set, they stay.

Observable effect: CapsLock engaged + Ctrl+F1 should send CSI 1;69P (1+4+64) but currently sends CSI 1;5P (1+4).

Implementation note: Adding lock bits to _encodeModifiers() requires a companion change — the modifiers > 0 check in the DISAMBIGUATE path must be replaced with ev.shiftKey || ev.altKey || ev.ctrlKey || ev.metaKey, otherwise CapsLock on + a would wrongly promote to CSI 97;65u instead of sending A. Spec § Disambiguate escape codes: "Lock modifiers are not reported for text producing keys, to keep them usable in legacy programs." Kitty masks with ~LOCK_MASK at the equivalent check (key_encoding.c#L189).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions