pub struct KeyboardEvent {
pub input: Option<KeyInput>,
pub physical_key: PhysicalKey,
pub state: KeyState,
pub modifiers: ModifierState,
}Expand description
This type represents a key event (press or release).
Each event carries a physical_key identifying
which key on the keyboard was pressed or released.
On presses, input contains the resolved KeyInput
after applying shift/Fn modifiers.
On releases it is None.
If you only care about basic input then you can just use input.
If you need raw information about pressed and released keys (games, custom bindings) you can use physical_key and the additional information in this struct.
Fields§
§input: Option<KeyInput>The resolved semantic input, if applicable.
Some on key press, None on key release. Release events should
be matched by physical_key, not by resolved input, since the modifier
state may have changed between press and release.
physical_key: PhysicalKeyWhich physical key was pressed or released. This is always independent of modifier keys.
state: KeyStateWhether the key was pressed or released.
modifiers: ModifierStateThe modifier state at the time of this event.
Trait Implementations§
Source§impl Clone for KeyboardEvent
impl Clone for KeyboardEvent
Source§fn clone(&self) -> KeyboardEvent
fn clone(&self) -> KeyboardEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more