Skip to main content

Module caps_lock

Module caps_lock 

Expand description

Heuristic Caps-Lock detection.

winit’s ModifiersState reports only held modifiers (SHIFT/CONTROL/ALT/ SUPER) — no lock-state bit, so Caps Lock can’t be read directly. We infer it from each typed letter and the Shift state that produced it:

typed letterShift heldconclusion
UPPER (A)noCaps Lock on
UPPER (A)yesCaps Lock off
lower (a)yesCaps Lock on (Shift inverts the lock)
lower (a)noCaps Lock off

Non-alphabetic input leaves the estimate unchanged. Standard approach for login screens; correct from the user’s first typed letter.

Structs§

CapsLockEstimate
A running estimate of whether Caps Lock is engaged, inferred from typed letters. Cheap to copy and to keep alive; update it by feeding each typed character (and the Shift state that produced it) through observe / observe_text.