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 letter | Shift held | conclusion |
|---|---|---|
UPPER (A) | no | Caps Lock on |
UPPER (A) | yes | Caps Lock off |
lower (a) | yes | Caps Lock on (Shift inverts the lock) |
lower (a) | no | Caps Lock off |
Non-alphabetic input leaves the estimate unchanged. Standard approach for login screens; correct from the user’s first typed letter.
Structs§
- Caps
Lock Estimate - 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.