cargo: Upgrade keyboard-types to 0.8.0 and xcomponent-sys to 0.3.4 (#38375)

With some adjustment for `NamedKey`. The two crates need to be bumped
together to avoid duplicate of `keyboard-types` action.

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-08-01 16:14:38 +08:00 committed by GitHub
parent a063b5e78a
commit 05ad9026f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 471 additions and 432 deletions

12
Cargo.lock generated
View file

@ -1359,7 +1359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"windows-sys 0.48.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -4664,9 +4664,9 @@ dependencies = [
[[package]] [[package]]
name = "keyboard-types" name = "keyboard-types"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" checksum = "fd6e0f18953c66af118a70064505bd3780a226d65b06553b7293fb8933067967"
dependencies = [ dependencies = [
"bitflags 2.9.1", "bitflags 2.9.1",
"serde", "serde",
@ -9921,7 +9921,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -10510,9 +10510,9 @@ dependencies = [
[[package]] [[package]]
name = "xcomponent-sys" name = "xcomponent-sys"
version = "0.3.3" version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e652372b831785d7d215786c83163c9eebb6c96c24e938c7f35d58af03a160" checksum = "329659c48163c2aad88ef9a68eb478f21307a563179d4304b5ead737543533c1"
dependencies = [ dependencies = [
"arkui-sys", "arkui-sys",
"keyboard-types", "keyboard-types",

View file

@ -87,7 +87,7 @@ indexmap = { version = "2.10.0", features = ["std"] }
ipc-channel = "0.20" ipc-channel = "0.20"
itertools = "0.14" itertools = "0.14"
js = { package = "mozjs", git = "https://github.com/servo/mozjs" } js = { package = "mozjs", git = "https://github.com/servo/mozjs" }
keyboard-types = "0.7" keyboard-types = { version = "0.8.0", features = ["webdriver", "serde"] }
kurbo = { version = "0.11.3", features = ["euclid"] } kurbo = { version = "0.11.3", features = ["euclid"] }
libc = "0.2" libc = "0.2"
log = "0.4" log = "0.4"

View file

@ -142,7 +142,7 @@ use fonts::SystemFontServiceProxy;
use ipc_channel::Error as IpcError; use ipc_channel::Error as IpcError;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use keyboard_types::{Key, KeyState, Modifiers}; use keyboard_types::{Key, KeyState, Modifiers, NamedKey};
use layout_api::{LayoutFactory, ScriptThreadFactory}; use layout_api::{LayoutFactory, ScriptThreadFactory};
use log::{debug, error, info, trace, warn}; use log::{debug, error, info, trace, warn};
use media::WindowGLContext; use media::WindowGLContext;
@ -2835,6 +2835,7 @@ where
} }
} }
#[allow(deprecated)]
fn update_active_keybord_modifiers(&mut self, event: &KeyboardEvent) { fn update_active_keybord_modifiers(&mut self, event: &KeyboardEvent) {
self.active_keyboard_modifiers = event.event.modifiers; self.active_keyboard_modifiers = event.event.modifiers;
@ -2842,23 +2843,27 @@ where
// either pressed or released, but `active_keyboard_modifiers` should track the subsequent // either pressed or released, but `active_keyboard_modifiers` should track the subsequent
// state. If this event will update that state, we need to ensure that we are tracking what // state. If this event will update that state, we need to ensure that we are tracking what
// the event changes. // the event changes.
let modified_modifier = match event.event.key { let Key::Named(named_key) = event.event.key else {
Key::Alt => Modifiers::ALT, return;
Key::AltGraph => Modifiers::ALT_GRAPH, };
Key::CapsLock => Modifiers::CAPS_LOCK,
Key::Control => Modifiers::CONTROL, let modified_modifier = match named_key {
Key::Fn => Modifiers::FN, NamedKey::Alt => Modifiers::ALT,
Key::FnLock => Modifiers::FN_LOCK, NamedKey::AltGraph => Modifiers::ALT_GRAPH,
Key::Meta => Modifiers::META, NamedKey::CapsLock => Modifiers::CAPS_LOCK,
Key::NumLock => Modifiers::NUM_LOCK, NamedKey::Control => Modifiers::CONTROL,
Key::ScrollLock => Modifiers::SCROLL_LOCK, NamedKey::Fn => Modifiers::FN,
Key::Shift => Modifiers::SHIFT, NamedKey::FnLock => Modifiers::FN_LOCK,
Key::Symbol => Modifiers::SYMBOL, NamedKey::Meta => Modifiers::META,
Key::SymbolLock => Modifiers::SYMBOL_LOCK, NamedKey::NumLock => Modifiers::NUM_LOCK,
Key::Hyper => Modifiers::HYPER, NamedKey::ScrollLock => Modifiers::SCROLL_LOCK,
NamedKey::Shift => Modifiers::SHIFT,
NamedKey::Symbol => Modifiers::SYMBOL,
NamedKey::SymbolLock => Modifiers::SYMBOL_LOCK,
NamedKey::Hyper => Modifiers::HYPER,
// The web doesn't make a distinction between these keys (there is only // The web doesn't make a distinction between these keys (there is only
// "meta") so map "super" to "meta". // "meta") so map "super" to "meta".
Key::Super => Modifiers::META, NamedKey::Super => Modifiers::META,
_ => return, _ => return,
}; };
match event.event.state { match event.event.state {

View file

@ -41,7 +41,7 @@ use html5ever::{LocalName, Namespace, QualName, local_name, ns};
use hyper_serde::Serde; use hyper_serde::Serde;
use ipc_channel::ipc; use ipc_channel::ipc;
use js::rust::{HandleObject, HandleValue, MutableHandleValue}; use js::rust::{HandleObject, HandleValue, MutableHandleValue};
use keyboard_types::{Code, Key, KeyState, Modifiers}; use keyboard_types::{Code, Key, KeyState, Modifiers, NamedKey};
use layout_api::{ use layout_api::{
PendingRestyle, ReflowGoal, RestyleReason, TrustedNodeAddress, node_id_from_scroll_id, PendingRestyle, ReflowGoal, RestyleReason, TrustedNodeAddress, node_id_from_scroll_id,
}; };
@ -2547,7 +2547,7 @@ impl Document {
let keyevent = KeyboardEvent::new( let keyevent = KeyboardEvent::new(
&self.window, &self.window,
DOMString::from(keyboard_event.event.state.to_string()), DOMString::from(keyboard_event.event.state.event_type()),
true, true,
true, true,
Some(&self.window), Some(&self.window),
@ -2607,7 +2607,8 @@ impl Document {
// however *when* we do it is up to us. // however *when* we do it is up to us.
// Here, we're dispatching it after the key event so the script has a chance to cancel it // Here, we're dispatching it after the key event so the script has a chance to cancel it
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27337 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27337
if (keyboard_event.event.key == Key::Enter || keyboard_event.event.code == Code::Space) && if (keyboard_event.event.key == Key::Named(NamedKey::Enter) ||
keyboard_event.event.code == Code::Space) &&
keyboard_event.event.state == KeyState::Up keyboard_event.event.state == KeyState::Up
{ {
if let Some(elem) = target.downcast::<Element>() { if let Some(elem) = target.downcast::<Element>() {
@ -2647,7 +2648,7 @@ impl Document {
let compositionevent = CompositionEvent::new( let compositionevent = CompositionEvent::new(
&self.window, &self.window,
DOMString::from(composition_event.state.to_string()), DOMString::from(composition_event.state.event_type()),
true, true,
cancelable, cancelable,
Some(&self.window), Some(&self.window),
@ -4045,7 +4046,7 @@ impl Document {
} }
fn is_character_value_key(key: &Key) -> bool { fn is_character_value_key(key: &Key) -> bool {
matches!(key, Key::Character(_) | Key::Enter) matches!(key, Key::Character(_) | Key::Named(NamedKey::Enter))
} }
#[derive(MallocSizeOf, PartialEq)] #[derive(MallocSizeOf, PartialEq)]

View file

@ -6,7 +6,7 @@ use std::cell::Cell;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use js::rust::HandleObject; use js::rust::HandleObject;
use keyboard_types::{Key, Modifiers}; use keyboard_types::{Key, Modifiers, NamedKey};
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding; use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding;
@ -43,7 +43,7 @@ impl KeyboardEvent {
KeyboardEvent { KeyboardEvent {
uievent: UIEvent::new_inherited(), uievent: UIEvent::new_inherited(),
key: DomRefCell::new(DOMString::new()), key: DomRefCell::new(DOMString::new()),
typed_key: DomRefCell::new(Key::Unidentified), typed_key: DomRefCell::new(Key::Named(NamedKey::Unidentified)),
code: DomRefCell::new(DOMString::new()), code: DomRefCell::new(DOMString::new()),
location: Cell::new(0), location: Cell::new(0),
modifiers: Cell::new(Modifiers::empty()), modifiers: Cell::new(Modifiers::empty()),
@ -180,7 +180,7 @@ impl KeyboardEventMethods<crate::DomTypeHolder> for KeyboardEvent {
init.parent.parent.parent.cancelable, init.parent.parent.parent.cancelable,
init.parent.parent.view.as_deref(), init.parent.parent.view.as_deref(),
init.parent.parent.detail, init.parent.parent.detail,
Key::Unidentified, Key::Named(NamedKey::Unidentified),
init.code.clone(), init.code.clone(),
init.location, init.location,
init.repeat, init.repeat,

View file

@ -9,7 +9,7 @@ use std::cmp::min;
use std::default::Default; use std::default::Default;
use std::ops::{Add, AddAssign, Range}; use std::ops::{Add, AddAssign, Range};
use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher}; use keyboard_types::{Key, KeyState, Modifiers, NamedKey, ShortcutMatcher};
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use crate::clipboard_provider::{ClipboardProvider, EmbedderClipboardProvider}; use crate::clipboard_provider::{ClipboardProvider, EmbedderClipboardProvider};
@ -921,75 +921,102 @@ impl<T: ClipboardProvider> TextInput<T> {
} }
KeyReaction::DispatchInput KeyReaction::DispatchInput
}) })
.shortcut(Modifiers::empty(), Key::Delete, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::Delete), || {
if self.delete_char(Direction::Forward) { if self.delete_char(Direction::Forward) {
KeyReaction::DispatchInput KeyReaction::DispatchInput
} else { } else {
KeyReaction::Nothing KeyReaction::Nothing
} }
}) })
.shortcut(Modifiers::empty(), Key::Backspace, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::Backspace), || {
if self.delete_char(Direction::Backward) { if self.delete_char(Direction::Backward) {
KeyReaction::DispatchInput KeyReaction::DispatchInput
} else { } else {
KeyReaction::Nothing KeyReaction::Nothing
} }
}) })
.optional_shortcut(macos, Modifiers::META, Key::ArrowLeft, || { .optional_shortcut(
self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select); macos,
KeyReaction::RedrawSelection Modifiers::META,
}) Key::Named(NamedKey::ArrowLeft),
.optional_shortcut(macos, Modifiers::META, Key::ArrowRight, || { || {
self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select); self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) },
.optional_shortcut(macos, Modifiers::META, Key::ArrowUp, || { )
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select); .optional_shortcut(
KeyReaction::RedrawSelection macos,
}) Modifiers::META,
.optional_shortcut(macos, Modifiers::META, Key::ArrowDown, || { Key::Named(NamedKey::ArrowRight),
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select); || {
KeyReaction::RedrawSelection self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select);
}) KeyReaction::RedrawSelection
.shortcut(Modifiers::ALT, Key::ArrowLeft, || { },
)
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowUp),
|| {
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
},
)
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowDown),
|| {
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
},
)
.shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowLeft), || {
self.adjust_horizontal_by_word(Direction::Backward, maybe_select); self.adjust_horizontal_by_word(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::ALT, Key::ArrowRight, || { .shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowRight), || {
self.adjust_horizontal_by_word(Direction::Forward, maybe_select); self.adjust_horizontal_by_word(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::ArrowLeft, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
self.adjust_horizontal_by_one(Direction::Backward, maybe_select); self.adjust_horizontal_by_one(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::ArrowRight, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowRight), || {
self.adjust_horizontal_by_one(Direction::Forward, maybe_select); self.adjust_horizontal_by_one(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::ArrowUp, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowUp), || {
self.adjust_vertical(-1, maybe_select); self.adjust_vertical(-1, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::ArrowDown, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
self.adjust_vertical(1, maybe_select); self.adjust_vertical(1, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::Enter, || self.handle_return()) .shortcut(Modifiers::empty(), Key::Named(NamedKey::Enter), || {
.optional_shortcut(macos, Modifiers::empty(), Key::Home, || { self.handle_return()
self.edit_point.index = UTF8Bytes::zero();
KeyReaction::RedrawSelection
}) })
.optional_shortcut(macos, Modifiers::empty(), Key::End, || { .optional_shortcut(
macos,
Modifiers::empty(),
Key::Named(NamedKey::Home),
|| {
self.edit_point.index = UTF8Bytes::zero();
KeyReaction::RedrawSelection
},
)
.optional_shortcut(macos, Modifiers::empty(), Key::Named(NamedKey::End), || {
self.edit_point.index = self.current_line_length(); self.edit_point.index = self.current_line_length();
self.assert_ok_selection(); self.assert_ok_selection();
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::PageUp, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::PageUp), || {
self.adjust_vertical(-28, maybe_select); self.adjust_vertical(-28, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
.shortcut(Modifiers::empty(), Key::PageDown, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::PageDown), || {
self.adjust_vertical(28, maybe_select); self.adjust_vertical(28, maybe_select);
KeyReaction::RedrawSelection KeyReaction::RedrawSelection
}) })
@ -998,7 +1025,7 @@ impl<T: ClipboardProvider> TextInput<T> {
self.insert_string(c.as_str()); self.insert_string(c.as_str());
return KeyReaction::DispatchInput; return KeyReaction::DispatchInput;
} }
if matches!(key, Key::Process) { if matches!(key, Key::Named(NamedKey::Process)) {
return KeyReaction::DispatchInput; return KeyReaction::DispatchInput;
} }
KeyReaction::Nothing KeyReaction::Nothing

View file

@ -628,6 +628,7 @@ pub(crate) unsafe fn windowproxy_from_handlevalue<D: crate::DomTypes>(
Ok(DomRoot::from_ref(&*ptr)) Ok(DomRoot::from_ref(&*ptr))
} }
#[allow(deprecated)]
impl<D: crate::DomTypes> EventModifierInit<D> { impl<D: crate::DomTypes> EventModifierInit<D> {
pub fn modifiers(&self) -> Modifiers { pub fn modifiers(&self) -> Modifiers {
let mut modifiers = Modifiers::empty(); let mut modifiers = Modifiers::empty();

View file

@ -85,7 +85,7 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use javascript_evaluator::JavaScriptEvaluator; use javascript_evaluator::JavaScriptEvaluator;
pub use keyboard_types::{ pub use keyboard_types::{
Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers, Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers, NamedKey,
}; };
use layout::LayoutFactoryImpl; use layout::LayoutFactoryImpl;
use log::{Log, Metadata, Record, debug, error, warn}; use log::{Log, Metadata, Record, debug, error, warn};

View file

@ -100,7 +100,7 @@ ohos-deviceinfo = "0.1.0"
ohos-abilitykit-sys = { version = "0.1.2", features = ["api-14"] } ohos-abilitykit-sys = { version = "0.1.2", features = ["api-14"] }
ohos-vsync = "0.1.3" ohos-vsync = "0.1.3"
ohos-window-manager-sys = { version = "0.1", features = ["api-14"] } ohos-window-manager-sys = { version = "0.1", features = ["api-14"] }
xcomponent-sys = { version = "0.3.3", features = ["api-14", "keyboard-types"] } xcomponent-sys = { version = "0.3.4", features = ["api-14", "keyboard-types"] }
[target.'cfg(any(target_os = "android", target_env = "ohos"))'.dependencies] [target.'cfg(any(target_os = "android", target_env = "ohos"))'.dependencies]
nix = { workspace = true, features = ["fs"] } nix = { workspace = true, features = ["fs"] }

View file

@ -10,7 +10,7 @@ use std::rc::Rc;
use crossbeam_channel::Receiver; use crossbeam_channel::Receiver;
use euclid::Vector2D; use euclid::Vector2D;
use keyboard_types::{Key, Modifiers, ShortcutMatcher}; use keyboard_types::{Key, Modifiers, NamedKey, ShortcutMatcher};
use log::{error, info}; use log::{error, info};
use servo::base::id::WebViewId; use servo::base::id::WebViewId;
use servo::config::pref; use servo::config::pref;
@ -418,39 +418,39 @@ impl RunningAppState {
.shortcut(CMD_OR_CONTROL, '0', || { .shortcut(CMD_OR_CONTROL, '0', || {
webview.reset_zoom(); webview.reset_zoom();
}) })
.shortcut(Modifiers::empty(), Key::PageDown, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::PageDown), || {
let scroll_location = ScrollLocation::Delta(Vector2D::new( let scroll_location = ScrollLocation::Delta(Vector2D::new(
0.0, 0.0,
self.inner().window.page_height() - 2.0 * LINE_HEIGHT, self.inner().window.page_height() - 2.0 * LINE_HEIGHT,
)); ));
webview.notify_scroll_event(scroll_location, origin); webview.notify_scroll_event(scroll_location, origin);
}) })
.shortcut(Modifiers::empty(), Key::PageUp, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::PageUp), || {
let scroll_location = ScrollLocation::Delta(Vector2D::new( let scroll_location = ScrollLocation::Delta(Vector2D::new(
0.0, 0.0,
-self.inner().window.page_height() + 2.0 * LINE_HEIGHT, -self.inner().window.page_height() + 2.0 * LINE_HEIGHT,
)); ));
webview.notify_scroll_event(scroll_location, origin); webview.notify_scroll_event(scroll_location, origin);
}) })
.shortcut(Modifiers::empty(), Key::Home, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::Home), || {
webview.notify_scroll_event(ScrollLocation::Start, origin); webview.notify_scroll_event(ScrollLocation::Start, origin);
}) })
.shortcut(Modifiers::empty(), Key::End, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::End), || {
webview.notify_scroll_event(ScrollLocation::End, origin); webview.notify_scroll_event(ScrollLocation::End, origin);
}) })
.shortcut(Modifiers::empty(), Key::ArrowUp, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowUp), || {
let location = ScrollLocation::Delta(Vector2D::new(0.0, -1.0 * LINE_HEIGHT)); let location = ScrollLocation::Delta(Vector2D::new(0.0, -1.0 * LINE_HEIGHT));
webview.notify_scroll_event(location, origin); webview.notify_scroll_event(location, origin);
}) })
.shortcut(Modifiers::empty(), Key::ArrowDown, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
let location = ScrollLocation::Delta(Vector2D::new(0.0, 1.0 * LINE_HEIGHT)); let location = ScrollLocation::Delta(Vector2D::new(0.0, 1.0 * LINE_HEIGHT));
webview.notify_scroll_event(location, origin); webview.notify_scroll_event(location, origin);
}) })
.shortcut(Modifiers::empty(), Key::ArrowLeft, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0)); let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0));
webview.notify_scroll_event(location, origin); webview.notify_scroll_event(location, origin);
}) })
.shortcut(Modifiers::empty(), Key::ArrowRight, || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowRight), || {
let location = ScrollLocation::Delta(Vector2D::new(LINE_WIDTH, 0.0)); let location = ScrollLocation::Delta(Vector2D::new(LINE_WIDTH, 0.0));
webview.notify_scroll_event(location, origin); webview.notify_scroll_event(location, origin);
}); });

View file

@ -11,7 +11,7 @@ use std::rc::Rc;
use std::time::Duration; use std::time::Duration;
use euclid::{Angle, Length, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D, Vector3D}; use euclid::{Angle, Length, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D, Vector3D};
use keyboard_types::{Modifiers, ShortcutMatcher}; use keyboard_types::ShortcutMatcher;
use log::{debug, info}; use log::{debug, info};
use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawWindowHandle}; use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawWindowHandle};
use servo::servo_config::pref; use servo::servo_config::pref;
@ -21,11 +21,11 @@ use servo::servo_geometry::{
use servo::webrender_api::ScrollLocation; use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel}; use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::{ use servo::{
Cursor, ImeEvent, InputEvent, Key, KeyState, KeyboardEvent, MouseButton as ServoMouseButton, Cursor, ImeEvent, InputEvent, Key, KeyState, KeyboardEvent, Modifiers,
MouseButtonAction, MouseButtonEvent, MouseLeaveEvent, MouseMoveEvent, MouseButton as ServoMouseButton, MouseButtonAction, MouseButtonEvent, MouseLeaveEvent,
OffscreenRenderingContext, RenderingContext, ScreenGeometry, Theme, TouchEvent, TouchEventType, MouseMoveEvent, NamedKey, OffscreenRenderingContext, RenderingContext, ScreenGeometry, Theme,
TouchId, WebRenderDebugOption, WebView, WheelDelta, WheelEvent, WheelMode, TouchEvent, TouchEventType, TouchId, WebRenderDebugOption, WebView, WheelDelta, WheelEvent,
WindowRenderingContext, WheelMode, WindowRenderingContext,
}; };
use surfman::{Context, Device}; use surfman::{Context, Device};
use url::Url; use url::Url;
@ -34,7 +34,7 @@ use winit::event::{
ElementState, Ime, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent, ElementState, Ime, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent,
}; };
use winit::event_loop::ActiveEventLoop; use winit::event_loop::ActiveEventLoop;
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey}; use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey as WinitNamedKey};
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use winit::platform::wayland::WindowAttributesExtWayland; use winit::platform::wayland::WindowAttributesExtWayland;
#[cfg(any(target_os = "linux", target_os = "windows"))] #[cfg(any(target_os = "linux", target_os = "windows"))]
@ -238,7 +238,7 @@ impl Window {
} }
if keyboard_event.event.state == KeyState::Down && if keyboard_event.event.state == KeyState::Down &&
keyboard_event.event.key == Key::Unidentified keyboard_event.event.key == Key::Named(NamedKey::Unidentified)
{ {
// If pressed and probably printable, we expect a ReceivedCharacter event. // If pressed and probably printable, we expect a ReceivedCharacter event.
// Wait for that to be received and don't queue any event right now. // Wait for that to be received and don't queue any event right now.
@ -246,7 +246,7 @@ impl Window {
.set(Some((keyboard_event, Some(winit_event.logical_key)))); .set(Some((keyboard_event, Some(winit_event.logical_key))));
return; return;
} else if keyboard_event.event.state == KeyState::Up && } else if keyboard_event.event.state == KeyState::Up &&
keyboard_event.event.key == Key::Unidentified keyboard_event.event.key == Key::Named(NamedKey::Unidentified)
{ {
// If release and probably printable, this is following a ReceiverCharacter event. // If release and probably printable, this is following a ReceiverCharacter event.
if let Some(key) = self.keys_down.borrow_mut().remove(&winit_event.logical_key) { if let Some(key) = self.keys_down.borrow_mut().remove(&winit_event.logical_key) {
@ -254,7 +254,7 @@ impl Window {
} }
} }
if keyboard_event.event.key != Key::Unidentified { if keyboard_event.event.key != Key::Named(NamedKey::Unidentified) {
self.last_pressed.set(None); self.last_pressed.set(None);
let xr_poses = self.xr_window_poses.borrow(); let xr_poses = self.xr_window_poses.borrow();
for xr_window_pose in &*xr_poses { for xr_window_pose in &*xr_poses {
@ -333,19 +333,19 @@ impl Window {
focused_webview focused_webview
.notify_input_event(InputEvent::EditingAction(servo::EditingActionEvent::Paste)) .notify_input_event(InputEvent::EditingAction(servo::EditingActionEvent::Paste))
}) })
.shortcut(Modifiers::CONTROL, Key::F9, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F9), || {
focused_webview.capture_webrender(); focused_webview.capture_webrender();
}) })
.shortcut(Modifiers::CONTROL, Key::F10, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F10), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::RenderTargetDebug); focused_webview.toggle_webrender_debugging(WebRenderDebugOption::RenderTargetDebug);
}) })
.shortcut(Modifiers::CONTROL, Key::F11, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F11), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::TextureCacheDebug); focused_webview.toggle_webrender_debugging(WebRenderDebugOption::TextureCacheDebug);
}) })
.shortcut(Modifiers::CONTROL, Key::F12, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F12), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::Profiler); focused_webview.toggle_webrender_debugging(WebRenderDebugOption::Profiler);
}) })
.shortcut(CMD_OR_ALT, Key::ArrowRight, || { .shortcut(CMD_OR_ALT, Key::Named(NamedKey::ArrowRight), || {
focused_webview.go_forward(1); focused_webview.go_forward(1);
}) })
.optional_shortcut( .optional_shortcut(
@ -356,7 +356,7 @@ impl Window {
focused_webview.go_forward(1); focused_webview.go_forward(1);
}, },
) )
.shortcut(CMD_OR_ALT, Key::ArrowLeft, || { .shortcut(CMD_OR_ALT, Key::Named(NamedKey::ArrowLeft), || {
focused_webview.go_back(1); focused_webview.go_back(1);
}) })
.optional_shortcut( .optional_shortcut(
@ -370,7 +370,7 @@ impl Window {
.optional_shortcut( .optional_shortcut(
self.get_fullscreen(), self.get_fullscreen(),
Modifiers::empty(), Modifiers::empty(),
Key::Escape, Key::Named(NamedKey::Escape),
|| focused_webview.exit_fullscreen(), || focused_webview.exit_fullscreen(),
) )
// Select the first 8 tabs via shortcuts // Select the first 8 tabs via shortcuts
@ -389,12 +389,12 @@ impl Window {
state.focus_webview_by_index(len - 1) state.focus_webview_by_index(len - 1)
} }
}) })
.shortcut(Modifiers::CONTROL, Key::PageDown, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::PageDown), || {
if let Some(index) = state.get_focused_webview_index() { if let Some(index) = state.get_focused_webview_index() {
state.focus_webview_by_index((index + 1) % state.webviews().len()) state.focus_webview_by_index((index + 1) % state.webviews().len())
} }
}) })
.shortcut(Modifiers::CONTROL, Key::PageUp, || { .shortcut(Modifiers::CONTROL, Key::Named(NamedKey::PageUp), || {
if let Some(index) = state.get_focused_webview_index() { if let Some(index) = state.get_focused_webview_index() {
let new_index = if index == 0 { let new_index = if index == 0 {
state.webviews().len() - 1 state.webviews().len() - 1
@ -925,10 +925,10 @@ impl XRWindowPose {
let mut x = 0.0; let mut x = 0.0;
let mut y = 0.0; let mut y = 0.0;
match input.logical_key { match input.logical_key {
LogicalKey::Named(NamedKey::ArrowUp) => x = 1.0, LogicalKey::Named(WinitNamedKey::ArrowUp) => x = 1.0,
LogicalKey::Named(NamedKey::ArrowDown) => x = -1.0, LogicalKey::Named(WinitNamedKey::ArrowDown) => x = -1.0,
LogicalKey::Named(NamedKey::ArrowLeft) => y = 1.0, LogicalKey::Named(WinitNamedKey::ArrowLeft) => y = 1.0,
LogicalKey::Named(NamedKey::ArrowRight) => y = -1.0, LogicalKey::Named(WinitNamedKey::ArrowRight) => y = -1.0,
_ => return, _ => return,
}; };
if modifiers.shift_key() { if modifiers.shift_key() {

View file

@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use keyboard_types::{Code, Key, KeyState, Location, Modifiers}; use keyboard_types::{Code, Key, KeyState, Location, Modifiers, NamedKey};
use servo::KeyboardEvent; use servo::KeyboardEvent;
use winit::event::{ElementState, KeyEvent}; use winit::event::{ElementState, KeyEvent};
use winit::keyboard::{ use winit::keyboard::{
Key as WinitKey, KeyCode, KeyLocation as WinitKeyLocation, ModifiersState, NamedKey, Key as WinitKey, KeyCode, KeyLocation as WinitKeyLocation, ModifiersState,
PhysicalKey, NamedKey as WinitNamedKey, PhysicalKey,
}; };
// Some shortcuts use Cmd on Mac and Control on other systems. // Some shortcuts use Cmd on Mac and Control on other systems.
@ -26,323 +26,327 @@ trait FromWinitKeyEvent {
fn from_winit_key_event(key_event: &KeyEvent) -> Self; fn from_winit_key_event(key_event: &KeyEvent) -> Self;
} }
#[allow(deprecated)]
impl FromWinitKeyEvent for Key { impl FromWinitKeyEvent for Key {
fn from_winit_key_event(key_event: &KeyEvent) -> Self { fn from_winit_key_event(key_event: &KeyEvent) -> Self {
let named_key = match key_event.logical_key { let named_key = match key_event.logical_key {
WinitKey::Named(named_key) => named_key, WinitKey::Named(named_key) => named_key,
WinitKey::Character(ref string) => return Key::Character(string.to_string()), WinitKey::Character(ref string) => return Key::Character(string.to_string()),
WinitKey::Unidentified(_) => return Key::Unidentified, WinitKey::Unidentified(_) | WinitKey::Dead(_) => {
WinitKey::Dead(_) => return Key::Unidentified, return Key::Named(NamedKey::Unidentified);
},
}; };
match named_key { match named_key {
NamedKey::AVRInput => Key::AVRInput, WinitNamedKey::AVRInput => Key::Named(NamedKey::AVRInput),
NamedKey::AVRPower => Key::AVRPower, WinitNamedKey::AVRPower => Key::Named(NamedKey::AVRPower),
NamedKey::Accept => Key::Accept, WinitNamedKey::Accept => Key::Named(NamedKey::Accept),
NamedKey::Again => Key::Again, WinitNamedKey::Again => Key::Named(NamedKey::Again),
NamedKey::AllCandidates => Key::AllCandidates, WinitNamedKey::AllCandidates => Key::Named(NamedKey::AllCandidates),
NamedKey::Alphanumeric => Key::Alphanumeric, WinitNamedKey::Alphanumeric => Key::Named(NamedKey::Alphanumeric),
NamedKey::Alt => Key::Alt, WinitNamedKey::Alt => Key::Named(NamedKey::Alt),
NamedKey::AltGraph => Key::AltGraph, WinitNamedKey::AltGraph => Key::Named(NamedKey::AltGraph),
NamedKey::AppSwitch => Key::AppSwitch, WinitNamedKey::AppSwitch => Key::Named(NamedKey::AppSwitch),
NamedKey::ArrowDown => Key::ArrowDown, WinitNamedKey::ArrowDown => Key::Named(NamedKey::ArrowDown),
NamedKey::ArrowLeft => Key::ArrowLeft, WinitNamedKey::ArrowLeft => Key::Named(NamedKey::ArrowLeft),
NamedKey::ArrowRight => Key::ArrowRight, WinitNamedKey::ArrowRight => Key::Named(NamedKey::ArrowRight),
NamedKey::ArrowUp => Key::ArrowUp, WinitNamedKey::ArrowUp => Key::Named(NamedKey::ArrowUp),
NamedKey::Attn => Key::Attn, WinitNamedKey::Attn => Key::Named(NamedKey::Attn),
NamedKey::AudioBalanceLeft => Key::AudioBalanceLeft, WinitNamedKey::AudioBalanceLeft => Key::Named(NamedKey::AudioBalanceLeft),
NamedKey::AudioBalanceRight => Key::AudioBalanceRight, WinitNamedKey::AudioBalanceRight => Key::Named(NamedKey::AudioBalanceRight),
NamedKey::AudioBassBoostDown => Key::AudioBassBoostDown, WinitNamedKey::AudioBassBoostDown => Key::Named(NamedKey::AudioBassBoostDown),
NamedKey::AudioBassBoostToggle => Key::AudioBassBoostToggle, WinitNamedKey::AudioBassBoostToggle => Key::Named(NamedKey::AudioBassBoostToggle),
NamedKey::AudioBassBoostUp => Key::AudioBassBoostUp, WinitNamedKey::AudioBassBoostUp => Key::Named(NamedKey::AudioBassBoostUp),
NamedKey::AudioFaderFront => Key::AudioFaderFront, WinitNamedKey::AudioFaderFront => Key::Named(NamedKey::AudioFaderFront),
NamedKey::AudioFaderRear => Key::AudioFaderRear, WinitNamedKey::AudioFaderRear => Key::Named(NamedKey::AudioFaderRear),
NamedKey::AudioSurroundModeNext => Key::AudioSurroundModeNext, WinitNamedKey::AudioSurroundModeNext => Key::Named(NamedKey::AudioSurroundModeNext),
NamedKey::AudioTrebleDown => Key::AudioTrebleDown, WinitNamedKey::AudioTrebleDown => Key::Named(NamedKey::AudioTrebleDown),
NamedKey::AudioTrebleUp => Key::AudioTrebleUp, WinitNamedKey::AudioTrebleUp => Key::Named(NamedKey::AudioTrebleUp),
NamedKey::AudioVolumeDown => Key::AudioVolumeDown, WinitNamedKey::AudioVolumeDown => Key::Named(NamedKey::AudioVolumeDown),
NamedKey::AudioVolumeMute => Key::AudioVolumeMute, WinitNamedKey::AudioVolumeMute => Key::Named(NamedKey::AudioVolumeMute),
NamedKey::AudioVolumeUp => Key::AudioVolumeUp, WinitNamedKey::AudioVolumeUp => Key::Named(NamedKey::AudioVolumeUp),
NamedKey::Backspace => Key::Backspace, WinitNamedKey::Backspace => Key::Named(NamedKey::Backspace),
NamedKey::BrightnessDown => Key::BrightnessDown, WinitNamedKey::BrightnessDown => Key::Named(NamedKey::BrightnessDown),
NamedKey::BrightnessUp => Key::BrightnessUp, WinitNamedKey::BrightnessUp => Key::Named(NamedKey::BrightnessUp),
NamedKey::BrowserBack => Key::BrowserBack, WinitNamedKey::BrowserBack => Key::Named(NamedKey::BrowserBack),
NamedKey::BrowserFavorites => Key::BrowserFavorites, WinitNamedKey::BrowserFavorites => Key::Named(NamedKey::BrowserFavorites),
NamedKey::BrowserForward => Key::BrowserForward, WinitNamedKey::BrowserForward => Key::Named(NamedKey::BrowserForward),
NamedKey::BrowserHome => Key::BrowserHome, WinitNamedKey::BrowserHome => Key::Named(NamedKey::BrowserHome),
NamedKey::BrowserRefresh => Key::BrowserRefresh, WinitNamedKey::BrowserRefresh => Key::Named(NamedKey::BrowserRefresh),
NamedKey::BrowserSearch => Key::BrowserSearch, WinitNamedKey::BrowserSearch => Key::Named(NamedKey::BrowserSearch),
NamedKey::BrowserStop => Key::BrowserStop, WinitNamedKey::BrowserStop => Key::Named(NamedKey::BrowserStop),
NamedKey::Call => Key::Call, WinitNamedKey::Call => Key::Named(NamedKey::Call),
NamedKey::Camera => Key::Camera, WinitNamedKey::Camera => Key::Named(NamedKey::Camera),
NamedKey::CameraFocus => Key::CameraFocus, WinitNamedKey::CameraFocus => Key::Named(NamedKey::CameraFocus),
NamedKey::Cancel => Key::Cancel, WinitNamedKey::Cancel => Key::Named(NamedKey::Cancel),
NamedKey::CapsLock => Key::CapsLock, WinitNamedKey::CapsLock => Key::Named(NamedKey::CapsLock),
NamedKey::ChannelDown => Key::ChannelDown, WinitNamedKey::ChannelDown => Key::Named(NamedKey::ChannelDown),
NamedKey::ChannelUp => Key::ChannelUp, WinitNamedKey::ChannelUp => Key::Named(NamedKey::ChannelUp),
NamedKey::Clear => Key::Clear, WinitNamedKey::Clear => Key::Named(NamedKey::Clear),
NamedKey::Close => Key::Close, WinitNamedKey::Close => Key::Named(NamedKey::Close),
NamedKey::ClosedCaptionToggle => Key::ClosedCaptionToggle, WinitNamedKey::ClosedCaptionToggle => Key::Named(NamedKey::ClosedCaptionToggle),
NamedKey::CodeInput => Key::CodeInput, WinitNamedKey::CodeInput => Key::Named(NamedKey::CodeInput),
NamedKey::ColorF0Red => Key::ColorF0Red, WinitNamedKey::ColorF0Red => Key::Named(NamedKey::ColorF0Red),
NamedKey::ColorF1Green => Key::ColorF1Green, WinitNamedKey::ColorF1Green => Key::Named(NamedKey::ColorF1Green),
NamedKey::ColorF2Yellow => Key::ColorF2Yellow, WinitNamedKey::ColorF2Yellow => Key::Named(NamedKey::ColorF2Yellow),
NamedKey::ColorF3Blue => Key::ColorF3Blue, WinitNamedKey::ColorF3Blue => Key::Named(NamedKey::ColorF3Blue),
NamedKey::ColorF4Grey => Key::ColorF4Grey, WinitNamedKey::ColorF4Grey => Key::Named(NamedKey::ColorF4Grey),
NamedKey::ColorF5Brown => Key::ColorF5Brown, WinitNamedKey::ColorF5Brown => Key::Named(NamedKey::ColorF5Brown),
NamedKey::Compose => Key::Compose, WinitNamedKey::Compose => Key::Named(NamedKey::Compose),
NamedKey::ContextMenu => Key::ContextMenu, WinitNamedKey::ContextMenu => Key::Named(NamedKey::ContextMenu),
NamedKey::Control => Key::Control, WinitNamedKey::Control => Key::Named(NamedKey::Control),
NamedKey::Convert => Key::Convert, WinitNamedKey::Convert => Key::Named(NamedKey::Convert),
NamedKey::Copy => Key::Copy, WinitNamedKey::Copy => Key::Named(NamedKey::Copy),
NamedKey::CrSel => Key::CrSel, WinitNamedKey::CrSel => Key::Named(NamedKey::CrSel),
NamedKey::Cut => Key::Cut, WinitNamedKey::Cut => Key::Named(NamedKey::Cut),
NamedKey::DVR => Key::DVR, WinitNamedKey::DVR => Key::Named(NamedKey::DVR),
NamedKey::Delete => Key::Delete, WinitNamedKey::Delete => Key::Named(NamedKey::Delete),
NamedKey::Dimmer => Key::Dimmer, WinitNamedKey::Dimmer => Key::Named(NamedKey::Dimmer),
NamedKey::DisplaySwap => Key::DisplaySwap, WinitNamedKey::DisplaySwap => Key::Named(NamedKey::DisplaySwap),
NamedKey::Eisu => Key::Eisu, WinitNamedKey::Eisu => Key::Named(NamedKey::Eisu),
NamedKey::Eject => Key::Eject, WinitNamedKey::Eject => Key::Named(NamedKey::Eject),
NamedKey::End => Key::End, WinitNamedKey::End => Key::Named(NamedKey::End),
NamedKey::EndCall => Key::EndCall, WinitNamedKey::EndCall => Key::Named(NamedKey::EndCall),
NamedKey::Enter => Key::Enter, WinitNamedKey::Enter => Key::Named(NamedKey::Enter),
NamedKey::EraseEof => Key::EraseEof, WinitNamedKey::EraseEof => Key::Named(NamedKey::EraseEof),
NamedKey::Escape => Key::Escape, WinitNamedKey::Escape => Key::Named(NamedKey::Escape),
NamedKey::ExSel => Key::ExSel, WinitNamedKey::ExSel => Key::Named(NamedKey::ExSel),
NamedKey::Execute => Key::Execute, WinitNamedKey::Execute => Key::Named(NamedKey::Execute),
NamedKey::Exit => Key::Exit, WinitNamedKey::Exit => Key::Named(NamedKey::Exit),
NamedKey::F1 => Key::F1, WinitNamedKey::F1 => Key::Named(NamedKey::F1),
NamedKey::F10 => Key::F10, WinitNamedKey::F10 => Key::Named(NamedKey::F10),
NamedKey::F11 => Key::F11, WinitNamedKey::F11 => Key::Named(NamedKey::F11),
NamedKey::F12 => Key::F12, WinitNamedKey::F12 => Key::Named(NamedKey::F12),
NamedKey::F13 => Key::F13, WinitNamedKey::F13 => Key::Named(NamedKey::F13),
NamedKey::F14 => Key::F14, WinitNamedKey::F14 => Key::Named(NamedKey::F14),
NamedKey::F15 => Key::F15, WinitNamedKey::F15 => Key::Named(NamedKey::F15),
NamedKey::F16 => Key::F16, WinitNamedKey::F16 => Key::Named(NamedKey::F16),
NamedKey::F17 => Key::F17, WinitNamedKey::F17 => Key::Named(NamedKey::F17),
NamedKey::F18 => Key::F18, WinitNamedKey::F18 => Key::Named(NamedKey::F18),
NamedKey::F19 => Key::F19, WinitNamedKey::F19 => Key::Named(NamedKey::F19),
NamedKey::F2 => Key::F2, WinitNamedKey::F2 => Key::Named(NamedKey::F2),
NamedKey::F20 => Key::F20, WinitNamedKey::F20 => Key::Named(NamedKey::F20),
NamedKey::F21 => Key::F21, WinitNamedKey::F21 => Key::Named(NamedKey::F21),
NamedKey::F22 => Key::F22, WinitNamedKey::F22 => Key::Named(NamedKey::F22),
NamedKey::F23 => Key::F23, WinitNamedKey::F23 => Key::Named(NamedKey::F23),
NamedKey::F24 => Key::F24, WinitNamedKey::F24 => Key::Named(NamedKey::F24),
NamedKey::F25 => Key::F25, WinitNamedKey::F25 => Key::Named(NamedKey::F25),
NamedKey::F26 => Key::F26, WinitNamedKey::F26 => Key::Named(NamedKey::F26),
NamedKey::F27 => Key::F27, WinitNamedKey::F27 => Key::Named(NamedKey::F27),
NamedKey::F28 => Key::F28, WinitNamedKey::F28 => Key::Named(NamedKey::F28),
NamedKey::F29 => Key::F29, WinitNamedKey::F29 => Key::Named(NamedKey::F29),
NamedKey::F3 => Key::F3, WinitNamedKey::F3 => Key::Named(NamedKey::F3),
NamedKey::F30 => Key::F30, WinitNamedKey::F30 => Key::Named(NamedKey::F30),
NamedKey::F31 => Key::F31, WinitNamedKey::F31 => Key::Named(NamedKey::F31),
NamedKey::F32 => Key::F32, WinitNamedKey::F32 => Key::Named(NamedKey::F32),
NamedKey::F33 => Key::F33, WinitNamedKey::F33 => Key::Named(NamedKey::F33),
NamedKey::F34 => Key::F34, WinitNamedKey::F34 => Key::Named(NamedKey::F34),
NamedKey::F35 => Key::F35, WinitNamedKey::F35 => Key::Named(NamedKey::F35),
NamedKey::F4 => Key::F4, WinitNamedKey::F4 => Key::Named(NamedKey::F4),
NamedKey::F5 => Key::F5, WinitNamedKey::F5 => Key::Named(NamedKey::F5),
NamedKey::F6 => Key::F6, WinitNamedKey::F6 => Key::Named(NamedKey::F6),
NamedKey::F7 => Key::F7, WinitNamedKey::F7 => Key::Named(NamedKey::F7),
NamedKey::F8 => Key::F8, WinitNamedKey::F8 => Key::Named(NamedKey::F8),
NamedKey::F9 => Key::F9, WinitNamedKey::F9 => Key::Named(NamedKey::F9),
NamedKey::FavoriteClear0 => Key::FavoriteClear0, WinitNamedKey::FavoriteClear0 => Key::Named(NamedKey::FavoriteClear0),
NamedKey::FavoriteClear1 => Key::FavoriteClear1, WinitNamedKey::FavoriteClear1 => Key::Named(NamedKey::FavoriteClear1),
NamedKey::FavoriteClear2 => Key::FavoriteClear2, WinitNamedKey::FavoriteClear2 => Key::Named(NamedKey::FavoriteClear2),
NamedKey::FavoriteClear3 => Key::FavoriteClear3, WinitNamedKey::FavoriteClear3 => Key::Named(NamedKey::FavoriteClear3),
NamedKey::FavoriteRecall0 => Key::FavoriteRecall0, WinitNamedKey::FavoriteRecall0 => Key::Named(NamedKey::FavoriteRecall0),
NamedKey::FavoriteRecall1 => Key::FavoriteRecall1, WinitNamedKey::FavoriteRecall1 => Key::Named(NamedKey::FavoriteRecall1),
NamedKey::FavoriteRecall2 => Key::FavoriteRecall2, WinitNamedKey::FavoriteRecall2 => Key::Named(NamedKey::FavoriteRecall2),
NamedKey::FavoriteRecall3 => Key::FavoriteRecall3, WinitNamedKey::FavoriteRecall3 => Key::Named(NamedKey::FavoriteRecall3),
NamedKey::FavoriteStore0 => Key::FavoriteStore0, WinitNamedKey::FavoriteStore0 => Key::Named(NamedKey::FavoriteStore0),
NamedKey::FavoriteStore1 => Key::FavoriteStore1, WinitNamedKey::FavoriteStore1 => Key::Named(NamedKey::FavoriteStore1),
NamedKey::FavoriteStore2 => Key::FavoriteStore2, WinitNamedKey::FavoriteStore2 => Key::Named(NamedKey::FavoriteStore2),
NamedKey::FavoriteStore3 => Key::FavoriteStore3, WinitNamedKey::FavoriteStore3 => Key::Named(NamedKey::FavoriteStore3),
NamedKey::FinalMode => Key::FinalMode, WinitNamedKey::FinalMode => Key::Named(NamedKey::FinalMode),
NamedKey::Find => Key::Find, WinitNamedKey::Find => Key::Named(NamedKey::Find),
NamedKey::Fn => Key::Fn, WinitNamedKey::Fn => Key::Named(NamedKey::Fn),
NamedKey::FnLock => Key::FnLock, WinitNamedKey::FnLock => Key::Named(NamedKey::FnLock),
NamedKey::GoBack => Key::GoBack, WinitNamedKey::GoBack => Key::Named(NamedKey::GoBack),
NamedKey::GoHome => Key::GoHome, WinitNamedKey::GoHome => Key::Named(NamedKey::GoHome),
NamedKey::GroupFirst => Key::GroupFirst, WinitNamedKey::GroupFirst => Key::Named(NamedKey::GroupFirst),
NamedKey::GroupLast => Key::GroupLast, WinitNamedKey::GroupLast => Key::Named(NamedKey::GroupLast),
NamedKey::GroupNext => Key::GroupNext, WinitNamedKey::GroupNext => Key::Named(NamedKey::GroupNext),
NamedKey::GroupPrevious => Key::GroupPrevious, WinitNamedKey::GroupPrevious => Key::Named(NamedKey::GroupPrevious),
NamedKey::Guide => Key::Guide, WinitNamedKey::Guide => Key::Named(NamedKey::Guide),
NamedKey::GuideNextDay => Key::GuideNextDay, WinitNamedKey::GuideNextDay => Key::Named(NamedKey::GuideNextDay),
NamedKey::GuidePreviousDay => Key::GuidePreviousDay, WinitNamedKey::GuidePreviousDay => Key::Named(NamedKey::GuidePreviousDay),
NamedKey::HangulMode => Key::HangulMode, WinitNamedKey::HangulMode => Key::Named(NamedKey::HangulMode),
NamedKey::HanjaMode => Key::HanjaMode, WinitNamedKey::HanjaMode => Key::Named(NamedKey::HanjaMode),
NamedKey::Hankaku => Key::Hankaku, WinitNamedKey::Hankaku => Key::Named(NamedKey::Hankaku),
NamedKey::HeadsetHook => Key::HeadsetHook, WinitNamedKey::HeadsetHook => Key::Named(NamedKey::HeadsetHook),
NamedKey::Help => Key::Help, WinitNamedKey::Help => Key::Named(NamedKey::Help),
NamedKey::Hibernate => Key::Hibernate, WinitNamedKey::Hibernate => Key::Named(NamedKey::Hibernate),
NamedKey::Hiragana => Key::Hiragana, WinitNamedKey::Hiragana => Key::Named(NamedKey::Hiragana),
NamedKey::HiraganaKatakana => Key::HiraganaKatakana, WinitNamedKey::HiraganaKatakana => Key::Named(NamedKey::HiraganaKatakana),
NamedKey::Home => Key::Home, WinitNamedKey::Home => Key::Named(NamedKey::Home),
NamedKey::Hyper => Key::Hyper, WinitNamedKey::Hyper => Key::Named(NamedKey::Hyper),
NamedKey::Info => Key::Info, WinitNamedKey::Info => Key::Named(NamedKey::Info),
NamedKey::Insert => Key::Insert, WinitNamedKey::Insert => Key::Named(NamedKey::Insert),
NamedKey::InstantReplay => Key::InstantReplay, WinitNamedKey::InstantReplay => Key::Named(NamedKey::InstantReplay),
NamedKey::JunjaMode => Key::JunjaMode, WinitNamedKey::JunjaMode => Key::Named(NamedKey::JunjaMode),
NamedKey::KanaMode => Key::KanaMode, WinitNamedKey::KanaMode => Key::Named(NamedKey::KanaMode),
NamedKey::KanjiMode => Key::KanjiMode, WinitNamedKey::KanjiMode => Key::Named(NamedKey::KanjiMode),
NamedKey::Katakana => Key::Katakana, WinitNamedKey::Katakana => Key::Named(NamedKey::Katakana),
NamedKey::Key11 => Key::Key11, WinitNamedKey::Key11 => Key::Named(NamedKey::Key11),
NamedKey::Key12 => Key::Key12, WinitNamedKey::Key12 => Key::Named(NamedKey::Key12),
NamedKey::LastNumberRedial => Key::LastNumberRedial, WinitNamedKey::LastNumberRedial => Key::Named(NamedKey::LastNumberRedial),
NamedKey::LaunchApplication1 => Key::LaunchApplication1, WinitNamedKey::LaunchApplication1 => Key::Named(NamedKey::LaunchApplication1),
NamedKey::LaunchApplication2 => Key::LaunchApplication2, WinitNamedKey::LaunchApplication2 => Key::Named(NamedKey::LaunchApplication2),
NamedKey::LaunchCalendar => Key::LaunchCalendar, WinitNamedKey::LaunchCalendar => Key::Named(NamedKey::LaunchCalendar),
NamedKey::LaunchContacts => Key::LaunchContacts, WinitNamedKey::LaunchContacts => Key::Named(NamedKey::LaunchContacts),
NamedKey::LaunchMail => Key::LaunchMail, WinitNamedKey::LaunchMail => Key::Named(NamedKey::LaunchMail),
NamedKey::LaunchMediaPlayer => Key::LaunchMediaPlayer, WinitNamedKey::LaunchMediaPlayer => Key::Named(NamedKey::LaunchMediaPlayer),
NamedKey::LaunchMusicPlayer => Key::LaunchMusicPlayer, WinitNamedKey::LaunchMusicPlayer => Key::Named(NamedKey::LaunchMusicPlayer),
NamedKey::LaunchPhone => Key::LaunchPhone, WinitNamedKey::LaunchPhone => Key::Named(NamedKey::LaunchPhone),
NamedKey::LaunchScreenSaver => Key::LaunchScreenSaver, WinitNamedKey::LaunchScreenSaver => Key::Named(NamedKey::LaunchScreenSaver),
NamedKey::LaunchSpreadsheet => Key::LaunchSpreadsheet, WinitNamedKey::LaunchSpreadsheet => Key::Named(NamedKey::LaunchSpreadsheet),
NamedKey::LaunchWebBrowser => Key::LaunchWebBrowser, WinitNamedKey::LaunchWebBrowser => Key::Named(NamedKey::LaunchWebBrowser),
NamedKey::LaunchWebCam => Key::LaunchWebCam, WinitNamedKey::LaunchWebCam => Key::Named(NamedKey::LaunchWebCam),
NamedKey::LaunchWordProcessor => Key::LaunchWordProcessor, WinitNamedKey::LaunchWordProcessor => Key::Named(NamedKey::LaunchWordProcessor),
NamedKey::Link => Key::Link, WinitNamedKey::Link => Key::Named(NamedKey::Link),
NamedKey::ListProgram => Key::ListProgram, WinitNamedKey::ListProgram => Key::Named(NamedKey::ListProgram),
NamedKey::LiveContent => Key::LiveContent, WinitNamedKey::LiveContent => Key::Named(NamedKey::LiveContent),
NamedKey::Lock => Key::Lock, WinitNamedKey::Lock => Key::Named(NamedKey::Lock),
NamedKey::LogOff => Key::LogOff, WinitNamedKey::LogOff => Key::Named(NamedKey::LogOff),
NamedKey::MailForward => Key::MailForward, WinitNamedKey::MailForward => Key::Named(NamedKey::MailForward),
NamedKey::MailReply => Key::MailReply, WinitNamedKey::MailReply => Key::Named(NamedKey::MailReply),
NamedKey::MailSend => Key::MailSend, WinitNamedKey::MailSend => Key::Named(NamedKey::MailSend),
NamedKey::MannerMode => Key::MannerMode, WinitNamedKey::MannerMode => Key::Named(NamedKey::MannerMode),
NamedKey::MediaApps => Key::MediaApps, WinitNamedKey::MediaApps => Key::Named(NamedKey::MediaApps),
NamedKey::MediaAudioTrack => Key::MediaAudioTrack, WinitNamedKey::MediaAudioTrack => Key::Named(NamedKey::MediaAudioTrack),
NamedKey::MediaClose => Key::MediaClose, WinitNamedKey::MediaClose => Key::Named(NamedKey::MediaClose),
NamedKey::MediaFastForward => Key::MediaFastForward, WinitNamedKey::MediaFastForward => Key::Named(NamedKey::MediaFastForward),
NamedKey::MediaLast => Key::MediaLast, WinitNamedKey::MediaLast => Key::Named(NamedKey::MediaLast),
NamedKey::MediaPause => Key::MediaPause, WinitNamedKey::MediaPause => Key::Named(NamedKey::MediaPause),
NamedKey::MediaPlay => Key::MediaPlay, WinitNamedKey::MediaPlay => Key::Named(NamedKey::MediaPlay),
NamedKey::MediaPlayPause => Key::MediaPlayPause, WinitNamedKey::MediaPlayPause => Key::Named(NamedKey::MediaPlayPause),
NamedKey::MediaRecord => Key::MediaRecord, WinitNamedKey::MediaRecord => Key::Named(NamedKey::MediaRecord),
NamedKey::MediaRewind => Key::MediaRewind, WinitNamedKey::MediaRewind => Key::Named(NamedKey::MediaRewind),
NamedKey::MediaSkipBackward => Key::MediaSkipBackward, WinitNamedKey::MediaSkipBackward => Key::Named(NamedKey::MediaSkipBackward),
NamedKey::MediaSkipForward => Key::MediaSkipForward, WinitNamedKey::MediaSkipForward => Key::Named(NamedKey::MediaSkipForward),
NamedKey::MediaStepBackward => Key::MediaStepBackward, WinitNamedKey::MediaStepBackward => Key::Named(NamedKey::MediaStepBackward),
NamedKey::MediaStepForward => Key::MediaStepForward, WinitNamedKey::MediaStepForward => Key::Named(NamedKey::MediaStepForward),
NamedKey::MediaStop => Key::MediaStop, WinitNamedKey::MediaStop => Key::Named(NamedKey::MediaStop),
NamedKey::MediaTopMenu => Key::MediaTopMenu, WinitNamedKey::MediaTopMenu => Key::Named(NamedKey::MediaTopMenu),
NamedKey::MediaTrackNext => Key::MediaTrackNext, WinitNamedKey::MediaTrackNext => Key::Named(NamedKey::MediaTrackNext),
NamedKey::MediaTrackPrevious => Key::MediaTrackPrevious, WinitNamedKey::MediaTrackPrevious => Key::Named(NamedKey::MediaTrackPrevious),
NamedKey::Meta => Key::Meta, WinitNamedKey::Meta => Key::Named(NamedKey::Meta),
NamedKey::MicrophoneToggle => Key::MicrophoneToggle, WinitNamedKey::MicrophoneToggle => Key::Named(NamedKey::MicrophoneToggle),
NamedKey::MicrophoneVolumeDown => Key::MicrophoneVolumeDown, WinitNamedKey::MicrophoneVolumeDown => Key::Named(NamedKey::MicrophoneVolumeDown),
NamedKey::MicrophoneVolumeMute => Key::MicrophoneVolumeMute, WinitNamedKey::MicrophoneVolumeMute => Key::Named(NamedKey::MicrophoneVolumeMute),
NamedKey::MicrophoneVolumeUp => Key::MicrophoneVolumeUp, WinitNamedKey::MicrophoneVolumeUp => Key::Named(NamedKey::MicrophoneVolumeUp),
NamedKey::ModeChange => Key::ModeChange, WinitNamedKey::ModeChange => Key::Named(NamedKey::ModeChange),
NamedKey::NavigateIn => Key::NavigateIn, WinitNamedKey::NavigateIn => Key::Named(NamedKey::NavigateIn),
NamedKey::NavigateNext => Key::NavigateNext, WinitNamedKey::NavigateNext => Key::Named(NamedKey::NavigateNext),
NamedKey::NavigateOut => Key::NavigateOut, WinitNamedKey::NavigateOut => Key::Named(NamedKey::NavigateOut),
NamedKey::NavigatePrevious => Key::NavigatePrevious, WinitNamedKey::NavigatePrevious => Key::Named(NamedKey::NavigatePrevious),
NamedKey::New => Key::New, WinitNamedKey::New => Key::Named(NamedKey::New),
NamedKey::NextCandidate => Key::NextCandidate, WinitNamedKey::NextCandidate => Key::Named(NamedKey::NextCandidate),
NamedKey::NextFavoriteChannel => Key::NextFavoriteChannel, WinitNamedKey::NextFavoriteChannel => Key::Named(NamedKey::NextFavoriteChannel),
NamedKey::NextUserProfile => Key::NextUserProfile, WinitNamedKey::NextUserProfile => Key::Named(NamedKey::NextUserProfile),
NamedKey::NonConvert => Key::NonConvert, WinitNamedKey::NonConvert => Key::Named(NamedKey::NonConvert),
NamedKey::Notification => Key::Notification, WinitNamedKey::Notification => Key::Named(NamedKey::Notification),
NamedKey::NumLock => Key::NumLock, WinitNamedKey::NumLock => Key::Named(NamedKey::NumLock),
NamedKey::OnDemand => Key::OnDemand, WinitNamedKey::OnDemand => Key::Named(NamedKey::OnDemand),
NamedKey::Open => Key::Open, WinitNamedKey::Open => Key::Named(NamedKey::Open),
NamedKey::PageDown => Key::PageDown, WinitNamedKey::PageDown => Key::Named(NamedKey::PageDown),
NamedKey::PageUp => Key::PageUp, WinitNamedKey::PageUp => Key::Named(NamedKey::PageUp),
NamedKey::Pairing => Key::Pairing, WinitNamedKey::Pairing => Key::Named(NamedKey::Pairing),
NamedKey::Paste => Key::Paste, WinitNamedKey::Paste => Key::Named(NamedKey::Paste),
NamedKey::Pause => Key::Pause, WinitNamedKey::Pause => Key::Named(NamedKey::Pause),
NamedKey::PinPDown => Key::PinPDown, WinitNamedKey::PinPDown => Key::Named(NamedKey::PinPDown),
NamedKey::PinPMove => Key::PinPMove, WinitNamedKey::PinPMove => Key::Named(NamedKey::PinPMove),
NamedKey::PinPToggle => Key::PinPToggle, WinitNamedKey::PinPToggle => Key::Named(NamedKey::PinPToggle),
NamedKey::PinPUp => Key::PinPUp, WinitNamedKey::PinPUp => Key::Named(NamedKey::PinPUp),
NamedKey::Play => Key::Play, WinitNamedKey::Play => Key::Named(NamedKey::Play),
NamedKey::PlaySpeedDown => Key::PlaySpeedDown, WinitNamedKey::PlaySpeedDown => Key::Named(NamedKey::PlaySpeedDown),
NamedKey::PlaySpeedReset => Key::PlaySpeedReset, WinitNamedKey::PlaySpeedReset => Key::Named(NamedKey::PlaySpeedReset),
NamedKey::PlaySpeedUp => Key::PlaySpeedUp, WinitNamedKey::PlaySpeedUp => Key::Named(NamedKey::PlaySpeedUp),
NamedKey::Power => Key::Power, WinitNamedKey::Power => Key::Named(NamedKey::Power),
NamedKey::PowerOff => Key::PowerOff, WinitNamedKey::PowerOff => Key::Named(NamedKey::PowerOff),
NamedKey::PreviousCandidate => Key::PreviousCandidate, WinitNamedKey::PreviousCandidate => Key::Named(NamedKey::PreviousCandidate),
NamedKey::Print => Key::Print, WinitNamedKey::Print => Key::Named(NamedKey::Print),
NamedKey::PrintScreen => Key::PrintScreen, WinitNamedKey::PrintScreen => Key::Named(NamedKey::PrintScreen),
NamedKey::Process => Key::Process, WinitNamedKey::Process => Key::Named(NamedKey::Process),
NamedKey::Props => Key::Props, WinitNamedKey::Props => Key::Named(NamedKey::Props),
NamedKey::RandomToggle => Key::RandomToggle, WinitNamedKey::RandomToggle => Key::Named(NamedKey::RandomToggle),
NamedKey::RcLowBattery => Key::RcLowBattery, WinitNamedKey::RcLowBattery => Key::Named(NamedKey::RcLowBattery),
NamedKey::RecordSpeedNext => Key::RecordSpeedNext, WinitNamedKey::RecordSpeedNext => Key::Named(NamedKey::RecordSpeedNext),
NamedKey::Redo => Key::Redo, WinitNamedKey::Redo => Key::Named(NamedKey::Redo),
NamedKey::RfBypass => Key::RfBypass, WinitNamedKey::RfBypass => Key::Named(NamedKey::RfBypass),
NamedKey::Romaji => Key::Romaji, WinitNamedKey::Romaji => Key::Named(NamedKey::Romaji),
NamedKey::STBInput => Key::STBInput, WinitNamedKey::STBInput => Key::Named(NamedKey::STBInput),
NamedKey::STBPower => Key::STBPower, WinitNamedKey::STBPower => Key::Named(NamedKey::STBPower),
NamedKey::Save => Key::Save, WinitNamedKey::Save => Key::Named(NamedKey::Save),
NamedKey::ScanChannelsToggle => Key::ScanChannelsToggle, WinitNamedKey::ScanChannelsToggle => Key::Named(NamedKey::ScanChannelsToggle),
NamedKey::ScreenModeNext => Key::ScreenModeNext, WinitNamedKey::ScreenModeNext => Key::Named(NamedKey::ScreenModeNext),
NamedKey::ScrollLock => Key::ScrollLock, WinitNamedKey::ScrollLock => Key::Named(NamedKey::ScrollLock),
NamedKey::Select => Key::Select, WinitNamedKey::Select => Key::Named(NamedKey::Select),
NamedKey::Settings => Key::Settings, WinitNamedKey::Settings => Key::Named(NamedKey::Settings),
NamedKey::Shift => Key::Shift, WinitNamedKey::Shift => Key::Named(NamedKey::Shift),
NamedKey::SingleCandidate => Key::SingleCandidate, WinitNamedKey::SingleCandidate => Key::Named(NamedKey::SingleCandidate),
NamedKey::Soft1 => Key::Soft1, WinitNamedKey::Soft1 => Key::Named(NamedKey::Soft1),
NamedKey::Soft2 => Key::Soft2, WinitNamedKey::Soft2 => Key::Named(NamedKey::Soft2),
NamedKey::Soft3 => Key::Soft3, WinitNamedKey::Soft3 => Key::Named(NamedKey::Soft3),
NamedKey::Soft4 => Key::Soft4, WinitNamedKey::Soft4 => Key::Named(NamedKey::Soft4),
NamedKey::Space => Key::Character(" ".to_string()), WinitNamedKey::Space => Key::Character(" ".to_string()),
NamedKey::SpeechCorrectionList => Key::SpeechCorrectionList, WinitNamedKey::SpeechCorrectionList => Key::Named(NamedKey::SpeechCorrectionList),
NamedKey::SpeechInputToggle => Key::SpeechInputToggle, WinitNamedKey::SpeechInputToggle => Key::Named(NamedKey::SpeechInputToggle),
NamedKey::SpellCheck => Key::SpellCheck, WinitNamedKey::SpellCheck => Key::Named(NamedKey::SpellCheck),
NamedKey::SplitScreenToggle => Key::SplitScreenToggle, WinitNamedKey::SplitScreenToggle => Key::Named(NamedKey::SplitScreenToggle),
NamedKey::Standby => Key::Standby, WinitNamedKey::Standby => Key::Named(NamedKey::Standby),
NamedKey::Subtitle => Key::Subtitle, WinitNamedKey::Subtitle => Key::Named(NamedKey::Subtitle),
NamedKey::Super => Key::Super, WinitNamedKey::Super => Key::Named(NamedKey::Super),
NamedKey::Symbol => Key::Symbol, WinitNamedKey::Symbol => Key::Named(NamedKey::Symbol),
NamedKey::SymbolLock => Key::SymbolLock, WinitNamedKey::SymbolLock => Key::Named(NamedKey::SymbolLock),
NamedKey::TV => Key::TV, WinitNamedKey::TV => Key::Named(NamedKey::TV),
NamedKey::TV3DMode => Key::TV3DMode, WinitNamedKey::TV3DMode => Key::Named(NamedKey::TV3DMode),
NamedKey::TVAntennaCable => Key::TVAntennaCable, WinitNamedKey::TVAntennaCable => Key::Named(NamedKey::TVAntennaCable),
NamedKey::TVAudioDescription => Key::TVAudioDescription, WinitNamedKey::TVAudioDescription => Key::Named(NamedKey::TVAudioDescription),
NamedKey::TVAudioDescriptionMixDown => Key::TVAudioDescriptionMixDown, WinitNamedKey::TVAudioDescriptionMixDown => {
NamedKey::TVAudioDescriptionMixUp => Key::TVAudioDescriptionMixUp, Key::Named(NamedKey::TVAudioDescriptionMixDown)
NamedKey::TVContentsMenu => Key::TVContentsMenu, },
NamedKey::TVDataService => Key::TVDataService, WinitNamedKey::TVAudioDescriptionMixUp => Key::Named(NamedKey::TVAudioDescriptionMixUp),
NamedKey::TVInput => Key::TVInput, WinitNamedKey::TVContentsMenu => Key::Named(NamedKey::TVContentsMenu),
NamedKey::TVInputComponent1 => Key::TVInputComponent1, WinitNamedKey::TVDataService => Key::Named(NamedKey::TVDataService),
NamedKey::TVInputComponent2 => Key::TVInputComponent2, WinitNamedKey::TVInput => Key::Named(NamedKey::TVInput),
NamedKey::TVInputComposite1 => Key::TVInputComposite1, WinitNamedKey::TVInputComponent1 => Key::Named(NamedKey::TVInputComponent1),
NamedKey::TVInputComposite2 => Key::TVInputComposite2, WinitNamedKey::TVInputComponent2 => Key::Named(NamedKey::TVInputComponent2),
NamedKey::TVInputHDMI1 => Key::TVInputHDMI1, WinitNamedKey::TVInputComposite1 => Key::Named(NamedKey::TVInputComposite1),
NamedKey::TVInputHDMI2 => Key::TVInputHDMI2, WinitNamedKey::TVInputComposite2 => Key::Named(NamedKey::TVInputComposite2),
NamedKey::TVInputHDMI3 => Key::TVInputHDMI3, WinitNamedKey::TVInputHDMI1 => Key::Named(NamedKey::TVInputHDMI1),
NamedKey::TVInputHDMI4 => Key::TVInputHDMI4, WinitNamedKey::TVInputHDMI2 => Key::Named(NamedKey::TVInputHDMI2),
NamedKey::TVInputVGA1 => Key::TVInputVGA1, WinitNamedKey::TVInputHDMI3 => Key::Named(NamedKey::TVInputHDMI3),
NamedKey::TVMediaContext => Key::TVMediaContext, WinitNamedKey::TVInputHDMI4 => Key::Named(NamedKey::TVInputHDMI4),
NamedKey::TVNetwork => Key::TVNetwork, WinitNamedKey::TVInputVGA1 => Key::Named(NamedKey::TVInputVGA1),
NamedKey::TVNumberEntry => Key::TVNumberEntry, WinitNamedKey::TVMediaContext => Key::Named(NamedKey::TVMediaContext),
NamedKey::TVPower => Key::TVPower, WinitNamedKey::TVNetwork => Key::Named(NamedKey::TVNetwork),
NamedKey::TVRadioService => Key::TVRadioService, WinitNamedKey::TVNumberEntry => Key::Named(NamedKey::TVNumberEntry),
NamedKey::TVSatellite => Key::TVSatellite, WinitNamedKey::TVPower => Key::Named(NamedKey::TVPower),
NamedKey::TVSatelliteBS => Key::TVSatelliteBS, WinitNamedKey::TVRadioService => Key::Named(NamedKey::TVRadioService),
NamedKey::TVSatelliteCS => Key::TVSatelliteCS, WinitNamedKey::TVSatellite => Key::Named(NamedKey::TVSatellite),
NamedKey::TVSatelliteToggle => Key::TVSatelliteToggle, WinitNamedKey::TVSatelliteBS => Key::Named(NamedKey::TVSatelliteBS),
NamedKey::TVTerrestrialAnalog => Key::TVTerrestrialAnalog, WinitNamedKey::TVSatelliteCS => Key::Named(NamedKey::TVSatelliteCS),
NamedKey::TVTerrestrialDigital => Key::TVTerrestrialDigital, WinitNamedKey::TVSatelliteToggle => Key::Named(NamedKey::TVSatelliteToggle),
NamedKey::TVTimer => Key::TVTimer, WinitNamedKey::TVTerrestrialAnalog => Key::Named(NamedKey::TVTerrestrialAnalog),
NamedKey::Tab => Key::Tab, WinitNamedKey::TVTerrestrialDigital => Key::Named(NamedKey::TVTerrestrialDigital),
NamedKey::Teletext => Key::Teletext, WinitNamedKey::TVTimer => Key::Named(NamedKey::TVTimer),
NamedKey::Undo => Key::Undo, WinitNamedKey::Tab => Key::Named(NamedKey::Tab),
NamedKey::VideoModeNext => Key::VideoModeNext, WinitNamedKey::Teletext => Key::Named(NamedKey::Teletext),
NamedKey::VoiceDial => Key::VoiceDial, WinitNamedKey::Undo => Key::Named(NamedKey::Undo),
NamedKey::WakeUp => Key::WakeUp, WinitNamedKey::VideoModeNext => Key::Named(NamedKey::VideoModeNext),
NamedKey::Wink => Key::Wink, WinitNamedKey::VoiceDial => Key::Named(NamedKey::VoiceDial),
NamedKey::Zenkaku => Key::Zenkaku, WinitNamedKey::WakeUp => Key::Named(NamedKey::WakeUp),
NamedKey::ZenkakuHankaku => Key::ZenkakuHankaku, WinitNamedKey::Wink => Key::Named(NamedKey::Wink),
NamedKey::ZoomIn => Key::ZoomIn, WinitNamedKey::Zenkaku => Key::Named(NamedKey::Zenkaku),
NamedKey::ZoomOut => Key::ZoomOut, WinitNamedKey::ZenkakuHankaku => Key::Named(NamedKey::ZenkakuHankaku),
NamedKey::ZoomToggle => Key::ZoomToggle, WinitNamedKey::ZoomIn => Key::Named(NamedKey::ZoomIn),
_ => Key::Unidentified, WinitNamedKey::ZoomOut => Key::Named(NamedKey::ZoomOut),
WinitNamedKey::ZoomToggle => Key::Named(NamedKey::ZoomToggle),
_ => Key::Named(NamedKey::Unidentified),
} }
} }
} }
@ -358,6 +362,7 @@ impl FromWinitKeyEvent for Location {
} }
} }
#[allow(deprecated)]
impl FromWinitKeyEvent for Code { impl FromWinitKeyEvent for Code {
fn from_winit_key_event(key_event: &KeyEvent) -> Self { fn from_winit_key_event(key_event: &KeyEvent) -> Self {
let key_code = match key_event.physical_key { let key_code = match key_event.physical_key {

View file

@ -7,7 +7,6 @@ use std::rc::Rc;
use dpi::PhysicalSize; use dpi::PhysicalSize;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use keyboard_types::{CompositionEvent, CompositionState};
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use raw_window_handle::{RawWindowHandle, WindowHandle}; use raw_window_handle::{RawWindowHandle, WindowHandle};
use servo::base::id::WebViewId; use servo::base::id::WebViewId;
@ -16,11 +15,12 @@ use servo::servo_geometry::DeviceIndependentPixel;
use servo::webrender_api::ScrollLocation; use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::{DeviceIntRect, DeviceIntSize, DevicePixel}; use servo::webrender_api::units::{DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::{ use servo::{
AllowOrDenyRequest, ContextMenuResult, ImeEvent, InputEvent, InputMethodType, Key, KeyState, AllowOrDenyRequest, CompositionEvent, CompositionState, ContextMenuResult, ImeEvent,
KeyboardEvent, LoadStatus, MediaSessionActionType, MediaSessionEvent, MouseButton, InputEvent, InputMethodType, Key, KeyState, KeyboardEvent, LoadStatus, MediaSessionActionType,
MouseButtonAction, MouseButtonEvent, MouseMoveEvent, NavigationRequest, PermissionRequest, MediaSessionEvent, MouseButton, MouseButtonAction, MouseButtonEvent, MouseMoveEvent, NamedKey,
RenderingContext, ScreenGeometry, Servo, ServoDelegate, ServoError, SimpleDialog, TouchEvent, NavigationRequest, PermissionRequest, RenderingContext, ScreenGeometry, Servo, ServoDelegate,
TouchEventType, TouchId, WebView, WebViewBuilder, WebViewDelegate, WindowRenderingContext, ServoError, SimpleDialog, TouchEvent, TouchEventType, TouchId, WebView, WebViewBuilder,
WebViewDelegate, WindowRenderingContext,
}; };
use url::Url; use url::Url;
@ -613,7 +613,7 @@ impl RunningAppState {
let active_webview = self.active_webview(); let active_webview = self.active_webview();
active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key( active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key(
KeyState::Down, KeyState::Down,
Key::Process, Key::Named(NamedKey::Process),
))); )));
active_webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition( active_webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
CompositionEvent { CompositionEvent {
@ -623,7 +623,7 @@ impl RunningAppState {
))); )));
active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key( active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key(
KeyState::Up, KeyState::Up,
Key::Process, Key::Named(NamedKey::Process),
))); )));
self.perform_updates(); self.perform_updates();
} }

View file

@ -13,7 +13,7 @@ use std::thread;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use keyboard_types::Key; use keyboard_types::{Key, NamedKey};
use log::{LevelFilter, debug, error, info, trace, warn}; use log::{LevelFilter, debug, error, info, trace, warn};
use napi_derive_ohos::{module_exports, napi}; use napi_derive_ohos::{module_exports, napi};
use napi_ohos::bindgen_prelude::Function; use napi_ohos::bindgen_prelude::Function;
@ -185,19 +185,19 @@ impl ServoAction {
InsertText(text) => servo.ime_insert_text(text.clone()), InsertText(text) => servo.ime_insert_text(text.clone()),
ImeDeleteForward(len) => { ImeDeleteForward(len) => {
for _ in 0..*len { for _ in 0..*len {
servo.key_down(Key::Delete); servo.key_down(Key::Named(NamedKey::Delete));
servo.key_up(Key::Delete); servo.key_up(Key::Named(NamedKey::Delete));
} }
}, },
ImeDeleteBackward(len) => { ImeDeleteBackward(len) => {
for _ in 0..*len { for _ in 0..*len {
servo.key_down(Key::Backspace); servo.key_down(Key::Named(NamedKey::Backspace));
servo.key_up(Key::Backspace); servo.key_up(Key::Named(NamedKey::Backspace));
} }
}, },
ImeSendEnter => { ImeSendEnter => {
servo.key_down(Key::Enter); servo.key_down(Key::Named(NamedKey::Enter));
servo.key_up(Key::Enter); servo.key_up(Key::Named(NamedKey::Enter));
}, },
Initialize(_init_opts) => { Initialize(_init_opts) => {
panic!("Received Initialize event, even though servo is already initialized") panic!("Received Initialize event, even though servo is already initialized")

View file

@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use keyboard_types::{Key, Modifiers}; use keyboard_types::{Key, Modifiers, NamedKey};
use script::test::DOMString; use script::test::DOMString;
use script::test::textinput::{ use script::test::textinput::{
ClipboardProvider, Direction, Lines, Selection, SelectionDirection, TextInput, TextPoint, ClipboardProvider, Direction, Lines, Selection, SelectionDirection, TextInput, TextPoint,
@ -488,10 +488,10 @@ fn test_navigation_keyboard_shortcuts() {
let mut textinput = text_input(Lines::Multiple, "hello áéc"); let mut textinput = text_input(Lines::Multiple, "hello áéc");
// Test that CMD + Right moves to the end of the current line. // Test that CMD + Right moves to the end of the current line.
textinput.handle_keydown_aux(Key::ArrowRight, Modifiers::META, true); textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowRight), Modifiers::META, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(11)); assert_eq!(textinput.edit_point().index, UTF8Bytes(11));
// Test that CMD + Right moves to the beginning of the current line. // Test that CMD + Right moves to the beginning of the current line.
textinput.handle_keydown_aux(Key::ArrowLeft, Modifiers::META, true); textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowLeft), Modifiers::META, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes::zero()); assert_eq!(textinput.edit_point().index, UTF8Bytes::zero());
// Test that CTRL + ALT + E moves to the end of the current line also. // Test that CTRL + ALT + E moves to the end of the current line also.
textinput.handle_keydown_aux( textinput.handle_keydown_aux(
@ -509,7 +509,7 @@ fn test_navigation_keyboard_shortcuts() {
assert_eq!(textinput.edit_point().index, UTF8Bytes::zero()); assert_eq!(textinput.edit_point().index, UTF8Bytes::zero());
// Test that ALT + Right moves to the end of the word. // Test that ALT + Right moves to the end of the word.
textinput.handle_keydown_aux(Key::ArrowRight, Modifiers::ALT, true); textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowRight), Modifiers::ALT, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(5)); assert_eq!(textinput.edit_point().index, UTF8Bytes(5));
// Test that CTRL + ALT + F moves to the end of the word also. // Test that CTRL + ALT + F moves to the end of the word also.
textinput.handle_keydown_aux( textinput.handle_keydown_aux(
@ -519,7 +519,7 @@ fn test_navigation_keyboard_shortcuts() {
); );
assert_eq!(textinput.edit_point().index, UTF8Bytes(11)); assert_eq!(textinput.edit_point().index, UTF8Bytes(11));
// Test that ALT + Left moves to the end of the word. // Test that ALT + Left moves to the end of the word.
textinput.handle_keydown_aux(Key::ArrowLeft, Modifiers::ALT, true); textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowLeft), Modifiers::ALT, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(6)); assert_eq!(textinput.edit_point().index, UTF8Bytes(6));
// Test that CTRL + ALT + B moves to the end of the word also. // Test that CTRL + ALT + B moves to the end of the word also.
textinput.handle_keydown_aux( textinput.handle_keydown_aux(
@ -860,7 +860,7 @@ fn test_select_all() {
#[test] #[test]
fn test_backspace_in_textarea_at_beginning_of_line() { fn test_backspace_in_textarea_at_beginning_of_line() {
let mut textinput = text_input(Lines::Multiple, "first line\n"); let mut textinput = text_input(Lines::Multiple, "first line\n");
textinput.handle_keydown_aux(Key::ArrowDown, Modifiers::empty(), false); textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowDown), Modifiers::empty(), false);
textinput.handle_keydown_aux(Key::Backspace, Modifiers::empty(), false); textinput.handle_keydown_aux(Key::Named(NamedKey::Backspace), Modifiers::empty(), false);
assert_eq!(textinput.get_content(), DOMString::from("first line")); assert_eq!(textinput.get_content(), DOMString::from("first line"));
} }