iced-yoda/core/src/keyboard/event.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

use crate::keyboard::key;
use crate::keyboard::{Key, Location, Modifiers};
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!_
///
/// [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 {
/// A keyboard key was pressed.
KeyPressed {
/// The key pressed.
key: Key,
/// The key pressed with all keyboard modifiers applied, except Ctrl.
modified_key: Key,
/// The physical key pressed.
physical_key: key::Physical,
/// The location of the key.
location: Location,
/// The state of the modifier keys.
modifiers: Modifiers,
2023-12-15 13:15:44 +01:00
/// The text produced by the key press, if any.
text: Option<SmolStr>,
},
2019-07-20 19:12:31 +02:00
/// A keyboard key was released.
KeyReleased {
/// The key released.
key: Key,
/// The physical key released.
physical_key: key::Physical,
/// The location of the key.
location: Location,
/// The state of the modifier keys.
modifiers: Modifiers,
2019-07-20 19:12:31 +02:00
},
/// The keyboard modifiers have changed.
ModifiersChanged(Modifiers),
2019-07-20 19:12:31 +02:00
}