pub struct Key {
pub code: KeyCode,
pub legend: Option<&'static str>,
pub icon: Option<&'static Icon>,
pub units: i32,
pub repeats: bool,
}Expand description
One key in the grid.
Fields§
§code: KeyCodeThe position this key stands for.
legend: Option<&'static str>A fixed legend, for keys whose meaning is not a character the layout
knows about. None means “ask the layout”.
icon: Option<&'static Icon>A picture to draw instead of the word.
Drawn rather than looked up, so it is the same on every machine. This
used to be a list of candidate glyphs tried against the loaded font,
because fonts disagree so completely about them: DejaVu has ⌫, ⇥,
⏎ and the triangles, a Mac’s Arial has none of those and no triangle
either, and the face that ships with denise-render has twenty-three
non-ASCII glyphs of which not one is either. That worked and left a
ceiling — no font, no symbol — which icons removes.
The word stays as legend regardless: it is what the
key still reports, which is what a test reads and what an
accessibility pass would.
units: i32Width, in half-widths of an ordinary letter key.
Halves rather than whole keys because the useful sizes are not multiples of a letter: Tab and Shift want one and a half, and a row that could only count in whole letters would have to round one of them wrong.
repeats: boolWhether holding it keeps sending it.
True for Backspace and nothing else, which is what a phone does and what
stops a slow finger typing aaaaaa. Holding a letter is a gesture with
a different meaning — the alternates a layout offers for it — and is not
this.