1mod ascii;
4mod consumer;
5mod hid;
6mod system_control;
7
8pub use ascii::{from_ascii, to_ascii};
9pub use consumer::ConsumerKey;
10pub use hid::HidKeyCode;
11use postcard::experimental::max_size::MaxSize;
12use serde::{Deserialize, Serialize};
13pub use system_control::SystemControlKey;
14
15#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord, MaxSize)]
17#[cfg_attr(feature = "defmt", derive(defmt::Format))]
18#[cfg_attr(feature = "_codegen", derive(strum::VariantNames))]
19#[non_exhaustive]
20#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
21#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
22pub enum SpecialKey {
23 GraveEscape,
25 Repeat,
27}
28
29#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord, MaxSize)]
30#[cfg_attr(feature = "defmt", derive(defmt::Format))]
31#[non_exhaustive]
32#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
33#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
34pub enum KeyCode {
35 Hid(HidKeyCode),
36 Consumer(ConsumerKey),
37 SystemControl(SystemControlKey),
38}
39
40impl KeyCode {
41 pub fn is_basic_keyboard_key(&self) -> bool {
42 matches!(self,
43 KeyCode::Hid(hid) if hid.process_as_consumer().is_none()
44 && hid.process_as_system_control().is_none()
45 && !hid.is_mouse_key()
46 )
47 }
48}