diff --git a/packages/html/Cargo.toml b/packages/html/Cargo.toml
index 956f9966f..ac5cd340f 100644
--- a/packages/html/Cargo.toml
+++ b/packages/html/Cargo.toml
@@ -17,6 +17,7 @@ serde_repr = { version = "0.1", optional = true }
wasm-bindgen = { version = "0.2.79", optional = true }
euclid = "0.22.7"
enumset = "1.0.11"
+keyboard-types = "0.6.2"
[dependencies.web-sys]
optional = true
diff --git a/packages/html/src/events.rs b/packages/html/src/events.rs
index 12c946eeb..414639523 100644
--- a/packages/html/src/events.rs
+++ b/packages/html/src/events.rs
@@ -3,9 +3,12 @@ use dioxus_core::exports::bumpalo;
use dioxus_core::*;
pub mod on {
+ //! Input events and associated data
+
use crate::geometry::{ClientPoint, ElementPoint, PagePoint, ScreenPoint};
- use crate::input::{Modifier, ModifierSet, MouseButton, MouseButtonSet};
+ use crate::input::{MouseButton, MouseButtonSet};
use enumset::EnumSet;
+ use keyboard_types::Modifiers;
use std::collections::HashMap;
use super::*;
@@ -593,26 +596,26 @@ pub mod on {
}
/// The set of modifier keys which were pressed when the event occurred
- pub fn modifiers(&self) -> ModifierSet {
- let mut set = EnumSet::empty();
+ pub fn modifiers(&self) -> Modifiers {
+ let mut modifiers = Modifiers::empty();
#[allow(deprecated)]
{
if self.alt_key {
- set |= Modifier::Alt;
+ modifiers.insert(Modifiers::ALT);
}
if self.ctrl_key {
- set |= Modifier::Ctrl;
+ modifiers.insert(Modifiers::CONTROL);
}
if self.meta_key {
- set |= Modifier::Meta;
+ modifiers.insert(Modifiers::META);
}
if self.shift_key {
- set |= Modifier::Shift;
+ modifiers.insert(Modifiers::SHIFT);
}
}
- set
+ modifiers
}
/// The set of mouse buttons which were held when the event occurred.
diff --git a/packages/html/src/geometry.rs b/packages/html/src/geometry.rs
index 38c497427..5a7c8112e 100644
--- a/packages/html/src/geometry.rs
+++ b/packages/html/src/geometry.rs
@@ -1,20 +1,28 @@
+//! Geometry primitives for representing e.g. mouse events
+
+/// A re-export of euclid, which we use for geometry primitives
pub use euclid;
+
use euclid::*;
/// Coordinate space relative to the screen
pub struct ScreenSpace;
+/// A point in ScreenSpace
pub type ScreenPoint = Point2D;
/// Coordinate space relative to the viewport
pub struct ClientSpace;
+/// A point in ClientSpace
pub type ClientPoint = Point2D;
/// Coordinate space relative to an element
pub struct ElementSpace;
+/// A point in ElementSpace
pub type ElementPoint = Point2D;
/// Coordinate space relative to the page
pub struct PageSpace;
+/// A point in PageSpace
pub type PagePoint = Point2D;
/// Coordinates of a point in the app's interface
diff --git a/packages/html/src/input.rs b/packages/html/src/input.rs
index 06787023b..7c722b384 100644
--- a/packages/html/src/input.rs
+++ b/packages/html/src/input.rs
@@ -1,18 +1,8 @@
+//! Data structures representing user input, such as modifier keys and mouse buttons
use enumset::{EnumSet, EnumSetType};
-// note: EnumSetType also derives Copy and Clone for some reason
-/// A modifier key, such as Alt or Ctrl
-#[derive(EnumSetType, Debug)]
-pub enum Modifier {
- Alt,
- Ctrl,
- /// The meta key (windows key, or command key)
- Meta,
- Shift,
-}
-
-/// A set of modifier keys
-pub type ModifierSet = EnumSet;
+/// A re-export of keyboard_types
+pub use keyboard_types;
/// A mouse button type (such as Primary/Secondary)
// note: EnumSetType also derives Copy and Clone for some reason
diff --git a/packages/html/src/lib.rs b/packages/html/src/lib.rs
index 3de940e25..705a076e4 100644
--- a/packages/html/src/lib.rs
+++ b/packages/html/src/lib.rs
@@ -17,11 +17,10 @@ mod elements;
mod events;
pub mod geometry;
mod global_attributes;
-mod input;
+pub mod input;
#[cfg(feature = "wasm-bind")]
mod web_sys_bind;
pub use elements::*;
pub use events::*;
pub use global_attributes::*;
-pub use input::*;