2024-09-13 03:02:07 +02:00
|
|
|
use crate::keyboard::key;
|
2024-01-16 13:28:00 +01:00
|
|
|
use crate::keyboard::{Key, Location, Modifiers};
|
2024-01-16 13:31:02 +01:00
|
|
|
use crate::SmolStr;
|
2019-07-20 19:12:31 +02:00
|
|
|
|
|
|
|
|
/// A keyboard event.
|
2019-09-05 09:59:38 +02:00
|
|
|
///
|
|
|
|
|
/// _**Note:** This type is largely incomplete! If you need to track
|
|
|
|
|
/// additional events, feel free to [open an issue] and share your use case!_
|
|
|
|
|
///
|
2021-12-23 09:34:37 +02:00
|
|
|
/// [open an issue]: https://github.com/iced-rs/iced/issues
|
2023-12-15 13:15:44 +01:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
2019-07-20 19:12:31 +02:00
|
|
|
pub enum Event {
|
2020-04-30 04:34:29 +02:00
|
|
|
/// A keyboard key was pressed.
|
|
|
|
|
KeyPressed {
|
2024-01-16 13:28:00 +01:00
|
|
|
/// The key pressed.
|
|
|
|
|
key: Key,
|
2020-04-30 04:34:29 +02:00
|
|
|
|
2024-09-13 03:07:52 +02:00
|
|
|
/// The key pressed with all keyboard modifiers applied, except Ctrl.
|
|
|
|
|
modified_key: Key,
|
|
|
|
|
|
2024-09-13 03:02:07 +02:00
|
|
|
/// The physical key pressed.
|
|
|
|
|
physical_key: key::Physical,
|
|
|
|
|
|
2024-01-16 13:28:00 +01:00
|
|
|
/// The location of the key.
|
|
|
|
|
location: Location,
|
|
|
|
|
|
|
|
|
|
/// The state of the modifier keys.
|
2020-11-25 05:31:45 +01:00
|
|
|
modifiers: Modifiers,
|
2023-12-15 13:15:44 +01:00
|
|
|
|
|
|
|
|
/// The text produced by the key press, if any.
|
2024-01-16 13:31:02 +01:00
|
|
|
text: Option<SmolStr>,
|
2020-04-30 04:34:29 +02:00
|
|
|
},
|
2019-07-20 19:12:31 +02:00
|
|
|
|
2020-04-30 04:34:29 +02:00
|
|
|
/// A keyboard key was released.
|
|
|
|
|
KeyReleased {
|
2024-01-16 13:28:00 +01:00
|
|
|
/// The key released.
|
|
|
|
|
key: Key,
|
|
|
|
|
|
|
|
|
|
/// The location of the key.
|
|
|
|
|
location: Location,
|
2019-12-06 04:01:48 +01:00
|
|
|
|
2024-01-16 13:28:00 +01:00
|
|
|
/// The state of the modifier keys.
|
2020-11-25 05:31:45 +01:00
|
|
|
modifiers: Modifiers,
|
2019-07-20 19:12:31 +02:00
|
|
|
},
|
|
|
|
|
|
2020-06-30 07:36:13 +02:00
|
|
|
/// The keyboard modifiers have changed.
|
2020-11-25 05:31:45 +01:00
|
|
|
ModifiersChanged(Modifiers),
|
2019-07-20 19:12:31 +02:00
|
|
|
}
|