iced_core/keyboard/
event.rs

1use crate::SmolStr;
2use crate::keyboard::key;
3use crate::keyboard::{Key, Location, Modifiers};
4
5/// A keyboard event.
6///
7/// _**Note:** This type is largely incomplete! If you need to track
8/// additional events, feel free to [open an issue] and share your use case!_
9///
10/// [open an issue]: https://github.com/iced-rs/iced/issues
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub enum Event {
13    /// A keyboard key was pressed.
14    KeyPressed {
15        /// The key pressed.
16        key: Key,
17
18        /// The key pressed with all keyboard modifiers applied, except Ctrl.
19        modified_key: Key,
20
21        /// The physical key pressed.
22        physical_key: key::Physical,
23
24        /// The location of the key.
25        location: Location,
26
27        /// The state of the modifier keys.
28        modifiers: Modifiers,
29
30        /// The text produced by the key press, if any.
31        text: Option<SmolStr>,
32    },
33
34    /// A keyboard key was released.
35    KeyReleased {
36        /// The key released.
37        key: Key,
38
39        /// The key released with all keyboard modifiers applied, except Ctrl.
40        modified_key: Key,
41
42        /// The physical key released.
43        physical_key: key::Physical,
44
45        /// The location of the key.
46        location: Location,
47
48        /// The state of the modifier keys.
49        modifiers: Modifiers,
50    },
51
52    /// The keyboard modifiers have changed.
53    ModifiersChanged(Modifiers),
54}