Skip to main content

Key

Struct Key 

Source
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: KeyCode

The 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: i32

Width, 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: bool

Whether 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.

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Key

Source§

impl Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrows as dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Mutably borrows as dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.