Keyboard input, text input elements

This commit is contained in:
2026-03-21 01:17:07 -04:00
parent 423df4ae1f
commit 84077b718f
13 changed files with 1451 additions and 52 deletions

57
lib/ui/src/keyboard.rs Normal file
View File

@@ -0,0 +1,57 @@
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct KeyboardModifiers {
pub shift: bool,
pub control: bool,
pub alt: bool,
pub super_key: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum KeyboardKey {
Character(String),
Enter,
Tab,
Escape,
Backspace,
Delete,
ArrowLeft,
ArrowRight,
ArrowUp,
ArrowDown,
Home,
End,
Unknown,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum KeyboardEventKind {
Pressed,
Released,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct KeyboardEvent {
pub keycode: u32,
pub kind: KeyboardEventKind,
pub key: KeyboardKey,
pub modifiers: KeyboardModifiers,
pub text: Option<String>,
}
impl KeyboardEvent {
pub fn new(
keycode: u32,
kind: KeyboardEventKind,
key: KeyboardKey,
modifiers: KeyboardModifiers,
text: Option<String>,
) -> Self {
Self {
keycode,
kind,
key,
modifiers,
text,
}
}
}