Key

Type Alias Key 

Source
pub type Key = Key<f64>;
Expand description

Type alias of crate::Key<f64>

Aliased Type§

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

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: Rgba<u8>

The colour of the key

§x: f64

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: f64

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: f64

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

§height: f64

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

§x2: f64

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: f64

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: f64

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: f64

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: f64

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

§rx: f64

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: f64

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.