use crate::{ConstInit, KeyDead, KeyMedia, KeyMod, KeyPad};
#[doc = crate::_tags!(interaction)]
#[doc = crate::_doc_location!("ui/event")]
#[doc = "See also [`KeyFfi`][super::KeyFfi]."]
#[rustfmt::skip]
#[non_exhaustive]
#[allow(missing_docs, reason = "alphanumerics")]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Key {
Backspace,
Enter,
Tab,
Escape,
Space,
Left,
Right,
Up,
Down,
Home,
End,
PageUp,
PageDown,
Delete,
Insert,
CapsLock,
ScrollLock,
NumLock,
PrintScreen,
Pause,
Menu,
Pad(KeyPad),
Mod(KeyMod),
Media(KeyMedia),
Fn(u8),
Char(char),
Dead(KeyDead),
A, B, C, D, E, F, G, H, I, J,
K, L, M, N, O, P, Q, R, S, T,
U, V, W, X, Y, Z,
Digit1, Digit2, Digit3, Digit4, Digit5,
Digit6, Digit7, Digit8, Digit9, Digit0,
Backquote,
Minus,
Equal,
BracketLeft,
BracketRight,
Semicolon,
Quote,
Backslash,
IntlBackslash,
Comma,
Dot,
Slash,
Scancode(u16),
#[default]
Unknown,
}
impl ConstInit for Key {
const INIT: Self = Self::Unknown;
}
#[allow(non_upper_case_globals)]
impl Key {
pub const Esc: Key = Key::Escape;
pub const Ins: Key = Key::Insert;
pub const Del: Key = Key::Delete;
}
#[allow(non_upper_case_globals)]
impl Key {
pub const EsOrdinal: Self = Self::Backquote;
pub const EsApostrophe: Self = Self::Minus;
pub const EsInvertedExclamationMark: Self = Self::Equal;
pub const EsBacktick: Self = Self::BracketLeft;
pub const EsPlus: Self = Self::BracketRight;
pub const EsEnye: Self = Self::Semicolon;
pub const EsAccent: Self = Self::Quote;
pub const EsCedilla: Self = Self::Backslash;
pub const EsBracket: Self = Self::IntlBackslash;
pub const EsComma: Self = Self::Comma;
pub const EsDot: Self = Self::Dot;
pub const EsMinus: Self = Self::Slash;
}
crate::sf! {
impl From<KeyMedia> for Key { fn from(code: KeyMedia) -> Key { Key::Media(code) } }
impl From<KeyMod> for Key { fn from(code: KeyMod) -> Key { Key::Mod(code) } }
impl From<KeyPad> for Key { fn from(code: KeyPad) -> Key { Key::Pad(code) } }
}