Merge branch 'bump-wry' into binary-protocal

This commit is contained in:
Evan Almloff committed 2023-10-13 09:45:11 -05:00
commit cb148cc881
6 files changed
+226 -204

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ frameworks = ["WebKit"]
[dependencies] [dependencies]
anyhow = "1.0.56" anyhow = "1.0.56"
log = "0.4.11" log = "0.4.11"
wry = "0.28.0" wry = "0.31.0"
dioxus = { path = "../../packages/dioxus" } dioxus = { path = "../../packages/dioxus" }
dioxus-desktop = { path = "../../packages/desktop", features = [ dioxus-desktop = { path = "../../packages/desktop", features = [
"tokio_runtime", "tokio_runtime",
+3 -1
View File
@@ -18,7 +18,7 @@ dioxus-hot-reload = { workspace = true, optional = true }
serde = "1.0.136" serde = "1.0.136"
serde_json = "1.0.79" serde_json = "1.0.79"
thiserror = { workspace = true } thiserror = { workspace = true }
wry = { version = "0.28.0", default-features = false, features = ["protocol", "file-drop"] } wry = { version = "0.31.0", default-features = false, features = ["protocol", "file-drop"] }
tracing = { workspace = true } tracing = { workspace = true }
futures-channel = { workspace = true } futures-channel = { workspace = true }
tokio = { workspace = true, features = [ tokio = { workspace = true, features = [
@@ -37,10 +37,12 @@ slab = { workspace = true }
futures-util = { workspace = true } futures-util = { workspace = true }
urlencoding = "2.1.2" urlencoding = "2.1.2"
async-trait = "0.1.68" async-trait = "0.1.68"
crossbeam-channel = "0.5.8"
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies] [target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
rfd = "0.11.3" rfd = "0.11.3"
global-hotkey = { git = "https://github.com/tauri-apps/global-hotkey" }
[target.'cfg(target_os = "ios")'.dependencies] [target.'cfg(target_os = "ios")'.dependencies]
objc = "0.2.7" objc = "0.2.7"
+6 -16
View File
@@ -5,9 +5,7 @@ use std::rc::Weak;
use crate::create_new_window; use crate::create_new_window;
use crate::events::IpcMessage; use crate::events::IpcMessage;
use crate::query::QueryEngine; use crate::query::QueryEngine;
use crate::shortcut::ShortcutId; use crate::shortcut::{HotKey, ShortcutId, ShortcutRegistry, ShortcutRegistryError};
use crate::shortcut::ShortcutRegistry;
use crate::shortcut::ShortcutRegistryError;
use crate::Config; use crate::Config;
use crate::WebviewHandler; use crate::WebviewHandler;
use dioxus_core::ScopeState; use dioxus_core::ScopeState;
@@ -15,7 +13,6 @@ use dioxus_core::VirtualDom;
#[cfg(all(feature = "hot-reload", debug_assertions))] #[cfg(all(feature = "hot-reload", debug_assertions))]
use dioxus_hot_reload::HotReloadMsg; use dioxus_hot_reload::HotReloadMsg;
use slab::Slab; use slab::Slab;
use wry::application::accelerator::Accelerator;
use wry::application::event::Event; use wry::application::event::Event;
use wry::application::event_loop::EventLoopProxy; use wry::application::event_loop::EventLoopProxy;
use wry::application::event_loop::EventLoopWindowTarget; use wry::application::event_loop::EventLoopWindowTarget;
@@ -251,11 +248,11 @@ impl DesktopService {
/// Linux: Only works on x11. See [this issue](https://github.com/tauri-apps/tao/issues/331) for more information. /// Linux: Only works on x11. See [this issue](https://github.com/tauri-apps/tao/issues/331) for more information.
pub fn create_shortcut( pub fn create_shortcut(
&self, &self,
accelerator: Accelerator, hotkey: HotKey,
callback: impl FnMut() + 'static, callback: impl FnMut() + 'static,
) -> Result<ShortcutId, ShortcutRegistryError> { ) -> Result<ShortcutId, ShortcutRegistryError> {
self.shortcut_manager self.shortcut_manager
.add_shortcut(accelerator, Box::new(callback)) .add_shortcut(hotkey, Box::new(callback))
} }
/// Remove a global shortcut /// Remove a global shortcut
@@ -387,17 +384,10 @@ impl WryWindowEventHandlerInner {
target: &EventLoopWindowTarget<UserWindowEvent>, target: &EventLoopWindowTarget<UserWindowEvent>,
) { ) {
// if this event does not apply to the window this listener cares about, return // if this event does not apply to the window this listener cares about, return
match event { if let Event::WindowEvent { window_id, .. } = event {
Event::WindowEvent { window_id, .. } if *window_id != self.window_id {
| Event::MenuEvent { return;
window_id: Some(window_id),
..
} => {
if *window_id != self.window_id {
return;
}
} }
_ => (),
} }
(self.handler)(event, target) (self.handler)(event, target)
} }
+13 -8
View File
@@ -10,16 +10,16 @@ mod escape;
mod eval; mod eval;
mod events; mod events;
mod file_upload; mod file_upload;
#[cfg(any(target_os = "ios", target_os = "android"))]
mod mobile_shortcut;
mod protocol; mod protocol;
mod query; mod query;
mod shortcut; mod shortcut;
mod waker; mod waker;
mod webview; mod webview;
#[cfg(any(target_os = "ios", target_os = "android"))]
mod mobile_shortcut;
use crate::query::QueryResult; use crate::query::QueryResult;
use crate::shortcut::GlobalHotKeyEvent;
pub use cfg::{Config, WindowCloseBehaviour}; pub use cfg::{Config, WindowCloseBehaviour};
pub use desktop_context::DesktopContext; pub use desktop_context::DesktopContext;
pub use desktop_context::{ pub use desktop_context::{
@@ -43,10 +43,11 @@ use tao::event_loop::{EventLoopProxy, EventLoopWindowTarget};
pub use tao::window::WindowBuilder; pub use tao::window::WindowBuilder;
use tao::{ use tao::{
event::{Event, StartCause, WindowEvent}, event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop}, event_loop::ControlFlow,
}; };
pub use wry; pub use wry;
pub use wry::application as tao; pub use wry::application as tao;
use wry::application::event_loop::EventLoopBuilder;
use wry::webview::WebView; use wry::webview::WebView;
use wry::{application::window::WindowId, webview::WebContext}; use wry::{application::window::WindowId, webview::WebContext};
@@ -118,7 +119,7 @@ pub fn launch_cfg(root: Component, config_builder: Config) {
/// } /// }
/// ``` /// ```
pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config) { pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config) {
let event_loop = EventLoop::<UserWindowEvent>::with_user_event(); let event_loop = EventLoopBuilder::<UserWindowEvent>::with_user_event().build();
let proxy = event_loop.create_proxy(); let proxy = event_loop.create_proxy();
@@ -155,7 +156,8 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
let queue = WebviewQueue::default(); let queue = WebviewQueue::default();
let shortcut_manager = ShortcutRegistry::new(&event_loop); let shortcut_manager = ShortcutRegistry::new();
let global_hotkey_channel = GlobalHotKeyEvent::receiver();
// move the props into a cell so we can pop it out later to create the first window // move the props into a cell so we can pop it out later to create the first window
// iOS panics if we create a window before the event loop is started // iOS panics if we create a window before the event loop is started
@@ -163,10 +165,14 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
let cfg = Rc::new(Cell::new(Some(cfg))); let cfg = Rc::new(Cell::new(Some(cfg)));
event_loop.run(move |window_event, event_loop, control_flow| { event_loop.run(move |window_event, event_loop, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Poll;
event_handlers.apply_event(&window_event, event_loop); event_handlers.apply_event(&window_event, event_loop);
if let Ok(event) = global_hotkey_channel.try_recv() {
shortcut_manager.call_handlers(event);
}
match window_event { match window_event {
Event::WindowEvent { Event::WindowEvent {
event, window_id, .. event, window_id, ..
@@ -366,7 +372,6 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
_ => {} _ => {}
}, },
Event::GlobalShortcutEvent(id) => shortcut_manager.call_handlers(id),
_ => {} _ => {}
} }
}) })
+54 -20
View File
@@ -1,29 +1,51 @@
#![allow(unused)] #![allow(unused)]
use super::*; use super::*;
use wry::application::accelerator::Accelerator; use std::str::FromStr;
use wry::application::event_loop::EventLoopWindowTarget; use wry::application::event_loop::EventLoopWindowTarget;
pub struct GlobalShortcut(); use dioxus_html::input_data::keyboard_types::Modifiers;
pub struct ShortcutManager();
impl ShortcutManager { #[derive(Clone, Debug)]
pub fn new<T>(target: &EventLoopWindowTarget<T>) -> Self { pub struct Accelerator;
Self()
#[derive(Clone, Copy)]
pub struct HotKey;
impl HotKey {
pub fn new(mods: Option<Modifiers>, key: Code) -> Self {
Self
} }
pub fn register( pub fn id(&self) -> u32 {
&mut self, 0
accelerator: Accelerator, }
) -> Result<GlobalShortcut, ShortcutManagerError> { }
Ok(GlobalShortcut())
impl FromStr for HotKey {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(HotKey)
}
}
pub struct GlobalHotKeyManager();
impl GlobalHotKeyManager {
pub fn new() -> Result<Self, HotkeyError> {
Ok(Self())
} }
pub fn unregister(&mut self, id: ShortcutId) -> Result<(), ShortcutManagerError> { pub fn register(&mut self, accelerator: HotKey) -> Result<HotKey, HotkeyError> {
Ok(HotKey)
}
pub fn unregister(&mut self, id: HotKey) -> Result<(), HotkeyError> {
Ok(()) Ok(())
} }
pub fn unregister_all(&mut self) -> Result<(), ShortcutManagerError> { pub fn unregister_all(&mut self, _: &[HotKey]) -> Result<(), HotkeyError> {
Ok(()) Ok(())
} }
} }
@@ -33,23 +55,35 @@ use std::{error, fmt};
/// An error whose cause the `ShortcutManager` to fail. /// An error whose cause the `ShortcutManager` to fail.
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug)] #[derive(Debug)]
pub enum ShortcutManagerError { pub enum HotkeyError {
AcceleratorAlreadyRegistered(Accelerator), AcceleratorAlreadyRegistered(Accelerator),
AcceleratorNotRegistered(Accelerator), AcceleratorNotRegistered(Accelerator),
InvalidAccelerator(String), HotKeyParseError(String),
} }
impl error::Error for ShortcutManagerError {} impl error::Error for HotkeyError {}
impl fmt::Display for ShortcutManagerError { impl fmt::Display for HotkeyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self { match self {
ShortcutManagerError::AcceleratorAlreadyRegistered(e) => { HotkeyError::AcceleratorAlreadyRegistered(e) => {
f.pad(&format!("hotkey already registered: {:?}", e)) f.pad(&format!("hotkey already registered: {:?}", e))
} }
ShortcutManagerError::AcceleratorNotRegistered(e) => { HotkeyError::AcceleratorNotRegistered(e) => {
f.pad(&format!("hotkey not registered: {:?}", e)) f.pad(&format!("hotkey not registered: {:?}", e))
} }
ShortcutManagerError::InvalidAccelerator(e) => e.fmt(f), HotkeyError::HotKeyParseError(e) => e.fmt(f),
} }
} }
} }
pub struct GlobalHotKeyEvent {
pub id: u32,
}
impl GlobalHotKeyEvent {
pub fn receiver() -> crossbeam_channel::Receiver<GlobalHotKeyEvent> {
crossbeam_channel::unbounded().1
}
}
pub(crate) type Code = dioxus_html::input_data::keyboard_types::Code;
+149 -158
View File
@@ -3,11 +3,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc, str::FromStr};
use dioxus_core::ScopeState; use dioxus_core::ScopeState;
use dioxus_html::input_data::keyboard_types::Modifiers; use dioxus_html::input_data::keyboard_types::Modifiers;
use slab::Slab; use slab::Slab;
use wry::application::{ use wry::application::keyboard::ModifiersState;
accelerator::{Accelerator, AcceleratorId},
event_loop::EventLoopWindowTarget,
keyboard::{KeyCode, ModifiersState},
};
use crate::{desktop_context::DesktopContext, use_window}; use crate::{desktop_context::DesktopContext, use_window};
@@ -20,22 +16,25 @@ use crate::{desktop_context::DesktopContext, use_window};
target_os = "netbsd", target_os = "netbsd",
target_os = "openbsd" target_os = "openbsd"
))] ))]
use wry::application::global_shortcut::{GlobalShortcut, ShortcutManager, ShortcutManagerError}; pub use global_hotkey::{
hotkey::{Code, HotKey},
Error as HotkeyError, GlobalHotKeyEvent, GlobalHotKeyManager,
};
#[cfg(any(target_os = "ios", target_os = "android"))] #[cfg(any(target_os = "ios", target_os = "android"))]
pub use crate::mobile_shortcut::*; pub use crate::mobile_shortcut::*;
#[derive(Clone)] #[derive(Clone)]
pub(crate) struct ShortcutRegistry { pub(crate) struct ShortcutRegistry {
manager: Rc<RefCell<ShortcutManager>>, manager: Rc<RefCell<GlobalHotKeyManager>>,
shortcuts: ShortcutMap, shortcuts: ShortcutMap,
} }
type ShortcutMap = Rc<RefCell<HashMap<AcceleratorId, Shortcut>>>; type ShortcutMap = Rc<RefCell<HashMap<u32, Shortcut>>>;
struct Shortcut { struct Shortcut {
#[allow(unused)] #[allow(unused)]
shortcut: GlobalShortcut, shortcut: HotKey,
callbacks: Slab<Box<dyn FnMut()>>, callbacks: Slab<Box<dyn FnMut()>>,
} }
@@ -54,15 +53,15 @@ impl Shortcut {
} }
impl ShortcutRegistry { impl ShortcutRegistry {
pub fn new<T>(target: &EventLoopWindowTarget<T>) -> Self { pub fn new() -> Self {
Self { Self {
manager: Rc::new(RefCell::new(ShortcutManager::new(target))), manager: Rc::new(RefCell::new(GlobalHotKeyManager::new().unwrap())),
shortcuts: Rc::new(RefCell::new(HashMap::new())), shortcuts: Rc::new(RefCell::new(HashMap::new())),
} }
} }
pub(crate) fn call_handlers(&self, id: AcceleratorId) { pub(crate) fn call_handlers(&self, id: GlobalHotKeyEvent) {
if let Some(Shortcut { callbacks, .. }) = self.shortcuts.borrow_mut().get_mut(&id) { if let Some(Shortcut { callbacks, .. }) = self.shortcuts.borrow_mut().get_mut(&id.id) {
for (_, callback) in callbacks.iter_mut() { for (_, callback) in callbacks.iter_mut() {
(callback)(); (callback)();
} }
@@ -71,10 +70,10 @@ impl ShortcutRegistry {
pub(crate) fn add_shortcut( pub(crate) fn add_shortcut(
&self, &self,
accelerator: Accelerator, hotkey: HotKey,
callback: Box<dyn FnMut()>, callback: Box<dyn FnMut()>,
) -> Result<ShortcutId, ShortcutRegistryError> { ) -> Result<ShortcutId, ShortcutRegistryError> {
let accelerator_id = accelerator.clone().id(); let accelerator_id = hotkey.clone().id();
let mut shortcuts = self.shortcuts.borrow_mut(); let mut shortcuts = self.shortcuts.borrow_mut();
Ok( Ok(
if let Some(callbacks) = shortcuts.get_mut(&accelerator_id) { if let Some(callbacks) = shortcuts.get_mut(&accelerator_id) {
@@ -84,12 +83,12 @@ impl ShortcutRegistry {
number: id, number: id,
} }
} else { } else {
match self.manager.borrow_mut().register(accelerator) { match self.manager.borrow_mut().register(hotkey) {
Ok(global_shortcut) => { Ok(_) => {
let mut slab = Slab::new(); let mut slab = Slab::new();
let id = slab.insert(callback); let id = slab.insert(callback);
let shortcut = Shortcut { let shortcut = Shortcut {
shortcut: global_shortcut, shortcut: hotkey,
callbacks: slab, callbacks: slab,
}; };
shortcuts.insert(accelerator_id, shortcut); shortcuts.insert(accelerator_id, shortcut);
@@ -98,7 +97,7 @@ impl ShortcutRegistry {
number: id, number: id,
} }
} }
Err(ShortcutManagerError::InvalidAccelerator(shortcut)) => { Err(HotkeyError::HotKeyParseError(shortcut)) => {
return Err(ShortcutRegistryError::InvalidShortcut(shortcut)) return Err(ShortcutRegistryError::InvalidShortcut(shortcut))
} }
Err(err) => return Err(ShortcutRegistryError::Other(Box::new(err))), Err(err) => return Err(ShortcutRegistryError::Other(Box::new(err))),
@@ -113,15 +112,6 @@ impl ShortcutRegistry {
callbacks.remove(id.number); callbacks.remove(id.number);
if callbacks.is_empty() { if callbacks.is_empty() {
if let Some(_shortcut) = shortcuts.remove(&id.id) { if let Some(_shortcut) = shortcuts.remove(&id.id) {
#[cfg(any(
target_os = "windows",
target_os = "macos",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
let _ = self.manager.borrow_mut().unregister(_shortcut.shortcut); let _ = self.manager.borrow_mut().unregister(_shortcut.shortcut);
} }
} }
@@ -130,8 +120,8 @@ impl ShortcutRegistry {
pub(crate) fn remove_all(&self) { pub(crate) fn remove_all(&self) {
let mut shortcuts = self.shortcuts.borrow_mut(); let mut shortcuts = self.shortcuts.borrow_mut();
shortcuts.clear(); let hotkeys: Vec<_> = shortcuts.drain().map(|(_, v)| v.shortcut).collect();
let _ = self.manager.borrow_mut().unregister_all(); let _ = self.manager.borrow_mut().unregister_all(&hotkeys);
} }
} }
@@ -148,7 +138,7 @@ pub enum ShortcutRegistryError {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// An global id for a shortcut. /// An global id for a shortcut.
pub struct ShortcutId { pub struct ShortcutId {
id: AcceleratorId, id: u32,
number: usize, number: usize,
} }
@@ -160,30 +150,30 @@ pub struct ShortcutHandle {
} }
pub trait IntoAccelerator { pub trait IntoAccelerator {
fn accelerator(&self) -> Accelerator; fn accelerator(&self) -> HotKey;
} }
impl IntoAccelerator for (dioxus_html::KeyCode, ModifiersState) { impl IntoAccelerator for (dioxus_html::KeyCode, ModifiersState) {
fn accelerator(&self) -> Accelerator { fn accelerator(&self) -> HotKey {
Accelerator::new(Some(self.1), self.0.into_key_code()) HotKey::new(Some(self.1.into_modifiers_state()), self.0.into_key_code())
} }
} }
impl IntoAccelerator for (ModifiersState, dioxus_html::KeyCode) { impl IntoAccelerator for (ModifiersState, dioxus_html::KeyCode) {
fn accelerator(&self) -> Accelerator { fn accelerator(&self) -> HotKey {
Accelerator::new(Some(self.0), self.1.into_key_code()) HotKey::new(Some(self.0.into_modifiers_state()), self.1.into_key_code())
} }
} }
impl IntoAccelerator for dioxus_html::KeyCode { impl IntoAccelerator for dioxus_html::KeyCode {
fn accelerator(&self) -> Accelerator { fn accelerator(&self) -> HotKey {
Accelerator::new(None, self.into_key_code()) HotKey::new(None, self.into_key_code())
} }
} }
impl IntoAccelerator for &str { impl IntoAccelerator for &str {
fn accelerator(&self) -> Accelerator { fn accelerator(&self) -> HotKey {
Accelerator::from_str(self).unwrap() HotKey::from_str(self).unwrap()
} }
} }
@@ -220,143 +210,144 @@ impl Drop for ShortcutHandle {
} }
pub trait IntoModifersState { pub trait IntoModifersState {
fn into_modifiers_state(self) -> ModifiersState; fn into_modifiers_state(self) -> Modifiers;
} }
impl IntoModifersState for ModifiersState { impl IntoModifersState for ModifiersState {
fn into_modifiers_state(self) -> ModifiersState { fn into_modifiers_state(self) -> Modifiers {
self let mut modifiers = Modifiers::default();
if self.shift_key() {
modifiers |= Modifiers::SHIFT;
}
if self.control_key() {
modifiers |= Modifiers::CONTROL;
}
if self.alt_key() {
modifiers |= Modifiers::ALT;
}
if self.super_key() {
modifiers |= Modifiers::META;
}
modifiers
} }
} }
impl IntoModifersState for Modifiers { impl IntoModifersState for Modifiers {
fn into_modifiers_state(self) -> ModifiersState { fn into_modifiers_state(self) -> Modifiers {
let mut state = ModifiersState::empty(); self
if self.contains(Modifiers::SHIFT) {
state |= ModifiersState::SHIFT
}
if self.contains(Modifiers::CONTROL) {
state |= ModifiersState::CONTROL
}
if self.contains(Modifiers::ALT) {
state |= ModifiersState::ALT
}
if self.contains(Modifiers::META) || self.contains(Modifiers::SUPER) {
state |= ModifiersState::SUPER
}
state
} }
} }
pub trait IntoKeyCode { pub trait IntoKeyCode {
fn into_key_code(self) -> KeyCode; fn into_key_code(self) -> Code;
} }
impl IntoKeyCode for KeyCode { impl IntoKeyCode for Code {
fn into_key_code(self) -> KeyCode { fn into_key_code(self) -> Code {
self self
} }
} }
impl IntoKeyCode for dioxus_html::KeyCode { impl IntoKeyCode for dioxus_html::KeyCode {
fn into_key_code(self) -> KeyCode { fn into_key_code(self) -> Code {
match self { match self {
dioxus_html::KeyCode::Backspace => KeyCode::Backspace, dioxus_html::KeyCode::Backspace => Code::Backspace,
dioxus_html::KeyCode::Tab => KeyCode::Tab, dioxus_html::KeyCode::Tab => Code::Tab,
dioxus_html::KeyCode::Clear => KeyCode::NumpadClear, dioxus_html::KeyCode::Clear => Code::NumpadClear,
dioxus_html::KeyCode::Enter => KeyCode::Enter, dioxus_html::KeyCode::Enter => Code::Enter,
dioxus_html::KeyCode::Shift => KeyCode::ShiftLeft, dioxus_html::KeyCode::Shift => Code::ShiftLeft,
dioxus_html::KeyCode::Ctrl => KeyCode::ControlLeft, dioxus_html::KeyCode::Ctrl => Code::ControlLeft,
dioxus_html::KeyCode::Alt => KeyCode::AltLeft, dioxus_html::KeyCode::Alt => Code::AltLeft,
dioxus_html::KeyCode::Pause => KeyCode::Pause, dioxus_html::KeyCode::Pause => Code::Pause,
dioxus_html::KeyCode::CapsLock => KeyCode::CapsLock, dioxus_html::KeyCode::CapsLock => Code::CapsLock,
dioxus_html::KeyCode::Escape => KeyCode::Escape, dioxus_html::KeyCode::Escape => Code::Escape,
dioxus_html::KeyCode::Space => KeyCode::Space, dioxus_html::KeyCode::Space => Code::Space,
dioxus_html::KeyCode::PageUp => KeyCode::PageUp, dioxus_html::KeyCode::PageUp => Code::PageUp,
dioxus_html::KeyCode::PageDown => KeyCode::PageDown, dioxus_html::KeyCode::PageDown => Code::PageDown,
dioxus_html::KeyCode::End => KeyCode::End, dioxus_html::KeyCode::End => Code::End,
dioxus_html::KeyCode::Home => KeyCode::Home, dioxus_html::KeyCode::Home => Code::Home,
dioxus_html::KeyCode::LeftArrow => KeyCode::ArrowLeft, dioxus_html::KeyCode::LeftArrow => Code::ArrowLeft,
dioxus_html::KeyCode::UpArrow => KeyCode::ArrowUp, dioxus_html::KeyCode::UpArrow => Code::ArrowUp,
dioxus_html::KeyCode::RightArrow => KeyCode::ArrowRight, dioxus_html::KeyCode::RightArrow => Code::ArrowRight,
dioxus_html::KeyCode::DownArrow => KeyCode::ArrowDown, dioxus_html::KeyCode::DownArrow => Code::ArrowDown,
dioxus_html::KeyCode::Insert => KeyCode::Insert, dioxus_html::KeyCode::Insert => Code::Insert,
dioxus_html::KeyCode::Delete => KeyCode::Delete, dioxus_html::KeyCode::Delete => Code::Delete,
dioxus_html::KeyCode::Num0 => KeyCode::Numpad0, dioxus_html::KeyCode::Num0 => Code::Numpad0,
dioxus_html::KeyCode::Num1 => KeyCode::Numpad1, dioxus_html::KeyCode::Num1 => Code::Numpad1,
dioxus_html::KeyCode::Num2 => KeyCode::Numpad2, dioxus_html::KeyCode::Num2 => Code::Numpad2,
dioxus_html::KeyCode::Num3 => KeyCode::Numpad3, dioxus_html::KeyCode::Num3 => Code::Numpad3,
dioxus_html::KeyCode::Num4 => KeyCode::Numpad4, dioxus_html::KeyCode::Num4 => Code::Numpad4,
dioxus_html::KeyCode::Num5 => KeyCode::Numpad5, dioxus_html::KeyCode::Num5 => Code::Numpad5,
dioxus_html::KeyCode::Num6 => KeyCode::Numpad6, dioxus_html::KeyCode::Num6 => Code::Numpad6,
dioxus_html::KeyCode::Num7 => KeyCode::Numpad7, dioxus_html::KeyCode::Num7 => Code::Numpad7,
dioxus_html::KeyCode::Num8 => KeyCode::Numpad8, dioxus_html::KeyCode::Num8 => Code::Numpad8,
dioxus_html::KeyCode::Num9 => KeyCode::Numpad9, dioxus_html::KeyCode::Num9 => Code::Numpad9,
dioxus_html::KeyCode::A => KeyCode::KeyA, dioxus_html::KeyCode::A => Code::KeyA,
dioxus_html::KeyCode::B => KeyCode::KeyB, dioxus_html::KeyCode::B => Code::KeyB,
dioxus_html::KeyCode::C => KeyCode::KeyC, dioxus_html::KeyCode::C => Code::KeyC,
dioxus_html::KeyCode::D => KeyCode::KeyD, dioxus_html::KeyCode::D => Code::KeyD,
dioxus_html::KeyCode::E => KeyCode::KeyE, dioxus_html::KeyCode::E => Code::KeyE,
dioxus_html::KeyCode::F => KeyCode::KeyF, dioxus_html::KeyCode::F => Code::KeyF,
dioxus_html::KeyCode::G => KeyCode::KeyG, dioxus_html::KeyCode::G => Code::KeyG,
dioxus_html::KeyCode::H => KeyCode::KeyH, dioxus_html::KeyCode::H => Code::KeyH,
dioxus_html::KeyCode::I => KeyCode::KeyI, dioxus_html::KeyCode::I => Code::KeyI,
dioxus_html::KeyCode::J => KeyCode::KeyJ, dioxus_html::KeyCode::J => Code::KeyJ,
dioxus_html::KeyCode::K => KeyCode::KeyK, dioxus_html::KeyCode::K => Code::KeyK,
dioxus_html::KeyCode::L => KeyCode::KeyL, dioxus_html::KeyCode::L => Code::KeyL,
dioxus_html::KeyCode::M => KeyCode::KeyM, dioxus_html::KeyCode::M => Code::KeyM,
dioxus_html::KeyCode::N => KeyCode::KeyN, dioxus_html::KeyCode::N => Code::KeyN,
dioxus_html::KeyCode::O => KeyCode::KeyO, dioxus_html::KeyCode::O => Code::KeyO,
dioxus_html::KeyCode::P => KeyCode::KeyP, dioxus_html::KeyCode::P => Code::KeyP,
dioxus_html::KeyCode::Q => KeyCode::KeyQ, dioxus_html::KeyCode::Q => Code::KeyQ,
dioxus_html::KeyCode::R => KeyCode::KeyR, dioxus_html::KeyCode::R => Code::KeyR,
dioxus_html::KeyCode::S => KeyCode::KeyS, dioxus_html::KeyCode::S => Code::KeyS,
dioxus_html::KeyCode::T => KeyCode::KeyT, dioxus_html::KeyCode::T => Code::KeyT,
dioxus_html::KeyCode::U => KeyCode::KeyU, dioxus_html::KeyCode::U => Code::KeyU,
dioxus_html::KeyCode::V => KeyCode::KeyV, dioxus_html::KeyCode::V => Code::KeyV,
dioxus_html::KeyCode::W => KeyCode::KeyW, dioxus_html::KeyCode::W => Code::KeyW,
dioxus_html::KeyCode::X => KeyCode::KeyX, dioxus_html::KeyCode::X => Code::KeyX,
dioxus_html::KeyCode::Y => KeyCode::KeyY, dioxus_html::KeyCode::Y => Code::KeyY,
dioxus_html::KeyCode::Z => KeyCode::KeyZ, dioxus_html::KeyCode::Z => Code::KeyZ,
dioxus_html::KeyCode::Numpad0 => KeyCode::Numpad0, dioxus_html::KeyCode::Numpad0 => Code::Numpad0,
dioxus_html::KeyCode::Numpad1 => KeyCode::Numpad1, dioxus_html::KeyCode::Numpad1 => Code::Numpad1,
dioxus_html::KeyCode::Numpad2 => KeyCode::Numpad2, dioxus_html::KeyCode::Numpad2 => Code::Numpad2,
dioxus_html::KeyCode::Numpad3 => KeyCode::Numpad3, dioxus_html::KeyCode::Numpad3 => Code::Numpad3,
dioxus_html::KeyCode::Numpad4 => KeyCode::Numpad4, dioxus_html::KeyCode::Numpad4 => Code::Numpad4,
dioxus_html::KeyCode::Numpad5 => KeyCode::Numpad5, dioxus_html::KeyCode::Numpad5 => Code::Numpad5,
dioxus_html::KeyCode::Numpad6 => KeyCode::Numpad6, dioxus_html::KeyCode::Numpad6 => Code::Numpad6,
dioxus_html::KeyCode::Numpad7 => KeyCode::Numpad7, dioxus_html::KeyCode::Numpad7 => Code::Numpad7,
dioxus_html::KeyCode::Numpad8 => KeyCode::Numpad8, dioxus_html::KeyCode::Numpad8 => Code::Numpad8,
dioxus_html::KeyCode::Numpad9 => KeyCode::Numpad9, dioxus_html::KeyCode::Numpad9 => Code::Numpad9,
dioxus_html::KeyCode::Multiply => KeyCode::NumpadMultiply, dioxus_html::KeyCode::Multiply => Code::NumpadMultiply,
dioxus_html::KeyCode::Add => KeyCode::NumpadAdd, dioxus_html::KeyCode::Add => Code::NumpadAdd,
dioxus_html::KeyCode::Subtract => KeyCode::NumpadSubtract, dioxus_html::KeyCode::Subtract => Code::NumpadSubtract,
dioxus_html::KeyCode::DecimalPoint => KeyCode::NumpadDecimal, dioxus_html::KeyCode::DecimalPoint => Code::NumpadDecimal,
dioxus_html::KeyCode::Divide => KeyCode::NumpadDivide, dioxus_html::KeyCode::Divide => Code::NumpadDivide,
dioxus_html::KeyCode::F1 => KeyCode::F1, dioxus_html::KeyCode::F1 => Code::F1,
dioxus_html::KeyCode::F2 => KeyCode::F2, dioxus_html::KeyCode::F2 => Code::F2,
dioxus_html::KeyCode::F3 => KeyCode::F3, dioxus_html::KeyCode::F3 => Code::F3,
dioxus_html::KeyCode::F4 => KeyCode::F4, dioxus_html::KeyCode::F4 => Code::F4,
dioxus_html::KeyCode::F5 => KeyCode::F5, dioxus_html::KeyCode::F5 => Code::F5,
dioxus_html::KeyCode::F6 => KeyCode::F6, dioxus_html::KeyCode::F6 => Code::F6,
dioxus_html::KeyCode::F7 => KeyCode::F7, dioxus_html::KeyCode::F7 => Code::F7,
dioxus_html::KeyCode::F8 => KeyCode::F8, dioxus_html::KeyCode::F8 => Code::F8,
dioxus_html::KeyCode::F9 => KeyCode::F9, dioxus_html::KeyCode::F9 => Code::F9,
dioxus_html::KeyCode::F10 => KeyCode::F10, dioxus_html::KeyCode::F10 => Code::F10,
dioxus_html::KeyCode::F11 => KeyCode::F11, dioxus_html::KeyCode::F11 => Code::F11,
dioxus_html::KeyCode::F12 => KeyCode::F12, dioxus_html::KeyCode::F12 => Code::F12,
dioxus_html::KeyCode::NumLock => KeyCode::NumLock, dioxus_html::KeyCode::NumLock => Code::NumLock,
dioxus_html::KeyCode::ScrollLock => KeyCode::ScrollLock, dioxus_html::KeyCode::ScrollLock => Code::ScrollLock,
dioxus_html::KeyCode::Semicolon => KeyCode::Semicolon, dioxus_html::KeyCode::Semicolon => Code::Semicolon,
dioxus_html::KeyCode::EqualSign => KeyCode::Equal, dioxus_html::KeyCode::EqualSign => Code::Equal,
dioxus_html::KeyCode::Comma => KeyCode::Comma, dioxus_html::KeyCode::Comma => Code::Comma,
dioxus_html::KeyCode::Period => KeyCode::Period, dioxus_html::KeyCode::Period => Code::Period,
dioxus_html::KeyCode::ForwardSlash => KeyCode::Slash, dioxus_html::KeyCode::ForwardSlash => Code::Slash,
dioxus_html::KeyCode::GraveAccent => KeyCode::Backquote, dioxus_html::KeyCode::GraveAccent => Code::Backquote,
dioxus_html::KeyCode::OpenBracket => KeyCode::BracketLeft, dioxus_html::KeyCode::OpenBracket => Code::BracketLeft,
dioxus_html::KeyCode::BackSlash => KeyCode::Backslash, dioxus_html::KeyCode::BackSlash => Code::Backslash,
dioxus_html::KeyCode::CloseBraket => KeyCode::BracketRight, dioxus_html::KeyCode::CloseBraket => Code::BracketRight,
dioxus_html::KeyCode::SingleQuote => KeyCode::Quote, dioxus_html::KeyCode::SingleQuote => Code::Quote,
key => panic!("Failed to convert {:?} to tao::keyboard::KeyCode, try using tao::keyboard::KeyCode directly", key), key => panic!("Failed to convert {:?} to tao::keyboard::KeyCode, try using tao::keyboard::KeyCode directly", key),
} }
} }