pub struct KeyboardState {
pub flags: [u128; 2],
}Expand description
Represents a state of pressed keys on a keyboard. Can be used to track the current state of the keyboard or to represent a keyboard state for hotkeys.
Tracks pressed keys using two 128-bit flags, allowing support for 256 keys.
Fields§
§flags: [u128; 2]Implementations§
Source§impl KeyboardState
impl KeyboardState
Sourcepub fn new() -> KeyboardState
pub fn new() -> KeyboardState
Creates a new KeyboardState with all keys released.
Sourcepub fn keydown(&mut self, key: u16)
pub fn keydown(&mut self, key: u16)
Marks a key as pressed.
Keys VK_Shift, VK_Control, and VK_Menu will be marked as pressed when either the left or right version is pressed.
Sourcepub fn sync(&mut self)
pub fn sync(&mut self)
Checks the state of each pressed key against the OS and removes them if they are not pressed.
Sourcepub fn get_async_key_state(key: u16) -> bool
pub fn get_async_key_state(key: u16) -> bool
Returns whether a key is currently pressed according to the OS.
Trait Implementations§
Source§impl Clone for KeyboardState
impl Clone for KeyboardState
Source§fn clone(&self) -> KeyboardState
fn clone(&self) -> KeyboardState
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 KeyboardState
impl Debug for KeyboardState
Source§impl Default for KeyboardState
impl Default for KeyboardState
Source§impl PartialEq for KeyboardState
impl PartialEq for KeyboardState
impl Copy for KeyboardState
impl Eq for KeyboardState
Auto Trait Implementations§
impl Freeze for KeyboardState
impl RefUnwindSafe for KeyboardState
impl Send for KeyboardState
impl Sync for KeyboardState
impl Unpin for KeyboardState
impl UnwindSafe for KeyboardState
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