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 /// Whether the event was the result of key repeat.
34 repeat: bool,
35 },
36
37 /// A keyboard key was released.
38 KeyReleased {
39 /// The key released.
40 key: Key,
41
42 /// The key released with all keyboard modifiers applied, except Ctrl.
43 modified_key: Key,
44
45 /// The physical key released.
46 physical_key: key::Physical,
47
48 /// The location of the key.
49 location: Location,
50
51 /// The state of the modifier keys.
52 modifiers: Modifiers,
53 },
54
55 /// The keyboard modifiers have changed.
56 ModifiersChanged(Modifiers),
57}