pub struct KeyboardInput {
pub scancode: ScanCode,
pub state: ElementState,
pub virtual_keycode: Option<VirtualKeyCode>,
}
Expand description
Describes a keyboard input event.
Fields§
§scancode: ScanCode
Identifies the physical key pressed
This should not change if the user adjusts the host’s keyboard map. Use when the physical location of the key is more important than the key’s host GUI semantics, such as for movement controls in a first-person game.
state: ElementState
Identifies the key is pressed, released or repeated.
virtual_keycode: Option<VirtualKeyCode>
Identifies the semantic meaning of the key
Use when the semantics of the key are more important than the physical location of the key, such as when implementing appropriate behavior for “page up.”
Implementations§
Source§impl KeyboardInput
impl KeyboardInput
pub fn is_key_pressed(&self, key_code: VirtualKeyCode) -> bool
pub fn is_key_released(&self, key_code: VirtualKeyCode) -> bool
pub fn is_key_repeated(&self, key_code: VirtualKeyCode) -> bool
pub fn is_key_triggered(&self, key_code: VirtualKeyCode) -> bool
Trait Implementations§
Source§impl Clone for KeyboardInput
impl Clone for KeyboardInput
Source§fn clone(&self) -> KeyboardInput
fn clone(&self) -> KeyboardInput
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for KeyboardInput
impl Debug for KeyboardInput
Source§impl Default for KeyboardInput
impl Default for KeyboardInput
Source§fn default() -> KeyboardInput
fn default() -> KeyboardInput
Returns the “default value” for a type. Read more
Source§impl Hash for KeyboardInput
impl Hash for KeyboardInput
Source§impl PartialEq for KeyboardInput
impl PartialEq for KeyboardInput
impl Copy for KeyboardInput
impl Eq for KeyboardInput
impl StructuralPartialEq for KeyboardInput
Auto Trait Implementations§
impl Freeze for KeyboardInput
impl RefUnwindSafe for KeyboardInput
impl Send for KeyboardInput
impl Sync for KeyboardInput
impl Unpin for KeyboardInput
impl UnwindSafe for KeyboardInput
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