Skip to main content

Module keycaps

Module keycaps 

Expand description

The words and symbols printed on the keys of the active keyboard layout.

A shortcut is shown the way the keyboard under the person’s hands spells it, not in the language of the interface: a German using a US layout reads Ctrl, the same German on a German layout reads Strg. Stored chords and matching stay canonical and English (Super, Ctrl, Alt, Shift, pageup); only what is painted changes.

The host publishes the layout the keyboard is typing with through set_active whenever it switches, and every label drawn afterwards reads it through active, so an open shortcut guide follows a layout switch on its next frame.

The Super key is always called Super on PC keyboards: the key carries a vendor logo rather than a word, and Super is the name the desktop’s documentation and onboarding use for it. Apple keyboards and XKB’s Mac layout variants use the symbols printed on Apple keycaps (⌘ ⌥ ⌃ ⇧).

Structs§

Keycaps
The legends of one keyboard: its layout’s language and whether it is an Apple keyboard.
ScopedKeycaps
Keeps a scoped layout in place on its thread.

Enums§

KeycapLanguage
The legend language of a keyboard layout: which words are printed on its modifier and navigation keys. Layouts whose keyboards carry English legends (Dutch, Portuguese, Nordic, Swiss, Japanese) differ from US English only in naming the right Alt key Alt Gr.

Functions§

active
The legends of the layout the keyboard is typing with now.
scoped
Read keycaps as the active layout on this thread only, until the returned guard drops; the previous scope comes back then, even when the holder panics. For code that renders labels under a given layout (a test asking for German keycaps) without changing what every other thread reads: set_active is process-wide, so a test using it would leak its layout into every test running beside it.
set_active
Publish the legends of the layout the keyboard just switched to.