pub struct KeyEvent { /* private fields */ }Expand description
A keyboard input event.
Holds the key, whether it went down or up, the modifier keys held with it and the text it typed.
Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub fn new(
key: Key,
text: impl Into<String>,
modifiers: Modifiers,
type_: KeyEventType,
) -> KeyEvent
pub fn new( key: Key, text: impl Into<String>, modifiers: Modifiers, type_: KeyEventType, ) -> KeyEvent
Creates a key event. text is what the key typed with the keyboard
layout and modifiers applied (Shift+A types “A”), empty for keys that
type nothing.
Sourcepub fn key_down(key: Key, text: impl Into<String>) -> KeyEvent
pub fn key_down(key: Key, text: impl Into<String>) -> KeyEvent
Creates a key down event with the given key and text.
Sourcepub fn key_down_with_modifiers(
key: Key,
text: impl Into<String>,
modifiers: Modifiers,
) -> KeyEvent
pub fn key_down_with_modifiers( key: Key, text: impl Into<String>, modifiers: Modifiers, ) -> KeyEvent
Creates a key down event with modifiers.
Sourcepub fn with_repeat_count(self, repeat_count: u32) -> KeyEvent
pub fn with_repeat_count(self, repeat_count: u32) -> KeyEvent
This event as the repeat_countth repeat of a held key.
Sourcepub fn type_(&self) -> KeyEventType
pub fn type_(&self) -> KeyEventType
Whether the key went down or up.
Sourcepub fn is_shift_pressed(&self) -> bool
pub fn is_shift_pressed(&self) -> bool
Whether a Shift key was held.
Sourcepub fn is_ctrl_pressed(&self) -> bool
pub fn is_ctrl_pressed(&self) -> bool
Whether a Control key was held.
Sourcepub fn is_alt_pressed(&self) -> bool
pub fn is_alt_pressed(&self) -> bool
Whether an Alt key was held.
Sourcepub fn is_meta_pressed(&self) -> bool
pub fn is_meta_pressed(&self) -> bool
Whether a Meta key was held.
Sourcepub fn utf16_code_point(&self) -> Option<u32>
pub fn utf16_code_point(&self) -> Option<u32>
The Unicode code point of the character this key typed, if it typed one.
Sourcepub fn native_key_event(&self) -> NativeKeyEvent
pub fn native_key_event(&self) -> NativeKeyEvent
What the platform reported beyond the key, such as the repeat count.
Sourcepub fn is_key_down(&self) -> bool
pub fn is_key_down(&self) -> bool
Returns true if this is a key down event.
Trait Implementations§
impl Eq for KeyEvent
impl StructuralPartialEq for KeyEvent
Auto Trait Implementations§
impl Forget for KeyEvent
impl Freeze for KeyEvent
impl RefUnwindSafe for KeyEvent
impl Send for KeyEvent
impl Sync for KeyEvent
impl Unpin for KeyEvent
impl UnsafeUnpin for KeyEvent
impl UnwindSafe for KeyEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more