Key

Struct Key 

Source
pub struct Key<T = f64>
where T: Real,
{
Show 19 fields pub legends: [Option<Legend>; 12], pub color: Color, pub x: T, pub y: T, pub width: T, pub height: T, pub x2: T, pub y2: T, pub width2: T, pub height2: T, pub rotation: T, pub rx: T, pub ry: T, pub profile: String, pub switch: Switch, pub ghosted: bool, pub stepped: bool, pub homing: bool, pub decal: bool,
}
Expand description

A struct representing a single key.

Fields§

§legends: [Option<Legend>; 12]

The key’s legends. This array is indexed in left to right, top to bottom order as shown in the image below.

alignment

Legends that are empty in KLE will be deserialised as None.

§color: Color

The colour of the key

§x: T

The X position of the key measured in keyboard units (typically 19.05 mm or 0.75 in).

KLE has some strange behaviour when it comes to positioning stepped and L-shaped keys. The ‘true’ X position of the top left corner will be less if the key’s x2 field is negative.

The actual position of the top left corner can be found using:

let x = key.x.min(key.x + key.x2);

This behaviour can be observed by placing an ISO enter in the top left corner in KLE; x is 0.25 and x2 is −0.25.

§y: T

The Y position of the key measured in keyboard units (typically 19.05 mm or 0.75 in).

KLE has some strange behaviour when it comes to positioning stepped and L-shaped keys. The ‘true’ Y position of the top left corner will be less if the key’s y2 field is negative.

The actual position of the top left corner can be found using:

let y = key.y.min(key.y + key.y2);

This behaviour can be observed by placing an ISO enter in the top left corner in KLE; x is 0.25 and x2 is −0.25.

§width: T

The width of the key measured in keyboard units (typically 19.05 mm or 0.75 in).

§height: T

The height of the key measured in keyboard units (typically 19.05 mm or 0.75 in).

§x2: T

The relative X position of a stepped or L-shaped part of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in).

This is set to 0.0 for regular keys, but is used for stepped caps lock and ISO enter keys, amongst others.

§y2: T

The relative Y position of a stepped or L-shaped part of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in).

This is set to 0.0 for regular keys, but is used for stepped caps lock and ISO enter keys, amongst others.

§width2: T

The width of a stepped or L-shaped part of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in).

This is equal to width for regular keys, but is used for stepped caps lock and ISO enter keys, amongst others.

§height2: T

The height of a stepped or L-shaped part of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in).

This is equal to height for regular keys, but is used for stepped caps lock and ISO enter keys, amongst others.

§rotation: T

The rotation of the key in degrees. Positive rotation values are clockwise.

§rx: T

The X coordinate for the centre of rotation of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in) from the top left corner of the layout.

§ry: T

The Y coordinate for the centre of rotation of the key. Measured in keyboard units (typically 19.05 mm or 0.75 in) from the top left corner of the layout.

§profile: String

The keycap profile and row number of the key.

KLE uses special rendering for "SA", "DSA", "DCS", "OEM", "CHICKLET", and "FLAT" profiles. It expects the row number to be one of "R1", "R2", "R3", "R4", "R5", or "SPACE", although it only uses special rendering for "SPACE".

KLE suggests the format "<profile> [<row>]", but it will recognise any string containing one of its supported profiles and/or rows. Any value is considered valid, but empty or unrecognised values are rendered using the unnamed default profile.

§switch: Switch

The key switch.

§ghosted: bool

Whether the key is ghosted.

§stepped: bool

Whether the key is stepped.

§homing: bool

Whether this is a homing key.

§decal: bool

Whether this is a decal.

Trait Implementations§

Source§

impl<T> Clone for Key<T>
where T: Real + Clone,

Source§

fn clone(&self) -> Key<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Key<T>
where T: Real + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Key<T>
where T: Real,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> PartialEq for Key<T>
where T: Real + PartialEq,

Source§

fn eq(&self, other: &Key<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> StructuralPartialEq for Key<T>
where T: Real,

Auto Trait Implementations§

§

impl<T> Freeze for Key<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Key<T>
where T: RefUnwindSafe,

§

impl<T> Send for Key<T>
where T: Send,

§

impl<T> Sync for Key<T>
where T: Sync,

§

impl<T> Unpin for Key<T>
where T: Unpin,

§

impl<T> UnwindSafe for Key<T>
where T: UnwindSafe,

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.