use crate::keyboard::{KeyKind, ModifierKey};
#[derive(Debug)]
pub struct KeyboardEvent {
pub(crate) inner: web_sys::KeyboardEvent,
}
impl KeyboardEvent {
pub fn key(&self) -> KeyKind {
let key = self.inner.key();
match key.as_str() {
"Unidentified" => KeyKind::Unidentified,
"Dead" => KeyKind::Dead,
_ => KeyKind::Key(key),
}
}
pub fn alt_key(&self) -> bool {
self.inner.alt_key()
}
pub fn ctrl_key(&self) -> bool {
self.inner.ctrl_key()
}
pub fn shift_key(&self) -> bool {
self.inner.shift_key()
}
pub fn modifier_key(&self, modifier: ModifierKey) -> bool {
self.inner.get_modifier_state(modifier.as_str())
}
pub fn is_composing(&self) -> bool {
self.inner.is_composing()
}
pub fn is_repeating(&self) -> bool {
self.inner.repeat()
}
}