pub struct KeyboardState {
pub modifiers: Modifiers,
/* private fields */
}Expand description
A stateful view of the primary pointer.
Fields§
§modifiers: ModifiersModifiers state.
Implementations§
Source§impl KeyboardState
impl KeyboardState
Sourcepub fn key_just_pressed(&self, key: Key) -> bool
pub fn key_just_pressed(&self, key: Key) -> bool
Return true if the key was pressed within the last frame with
any Location.
Sourcepub fn key_str_just_pressed(&self, s: &str) -> bool
pub fn key_str_just_pressed(&self, s: &str) -> bool
Return true if a Key::Character matching s was pressed within the last frame
with any Location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_just_pressed.
Sourcepub fn key_just_pressed_location(&self, key: Key, location: Location) -> bool
pub fn key_just_pressed_location(&self, key: Key, location: Location) -> bool
Return true if the key was pressed within the last frame with location.
Sourcepub fn key_str_just_pressed_location(&self, s: &str, location: Location) -> bool
pub fn key_str_just_pressed_location(&self, s: &str, location: Location) -> bool
Return true if a Key::Character matching s was pressed within the last frame
with location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_just_pressed_location.
Sourcepub fn code_just_pressed(&self, code: Code) -> bool
pub fn code_just_pressed(&self, code: Code) -> bool
Return true if the Code was pressed within the last frame.
Sourcepub fn key_just_released(&self, key: Key) -> bool
pub fn key_just_released(&self, key: Key) -> bool
Return true if the key was released within the last frame with
any Location.
Sourcepub fn key_str_just_released(&self, s: &str) -> bool
pub fn key_str_just_released(&self, s: &str) -> bool
Return true if a Key::Character matching s was released within the last frame
with any Location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_just_released.
Sourcepub fn key_just_released_location(&self, key: Key, location: Location) -> bool
pub fn key_just_released_location(&self, key: Key, location: Location) -> bool
Return true if the key was released within the last frame with location.
Sourcepub fn key_str_just_released_location(
&self,
s: &str,
location: Location,
) -> bool
pub fn key_str_just_released_location( &self, s: &str, location: Location, ) -> bool
Return true if a Key::Character matching s was released within the last frame
with location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_just_released_location.
Sourcepub fn code_just_released(&self, code: Code) -> bool
pub fn code_just_released(&self, code: Code) -> bool
Return true if the Code was released within the last frame.
Sourcepub fn is_any_down(&self) -> bool
pub fn is_any_down(&self) -> bool
Return true if any key is currently held down.
Sourcepub fn key_down(&self, key: Key) -> bool
pub fn key_down(&self, key: Key) -> bool
Return true if the key is currently pressed with any Location.
For a Key::Character, you can use key_str_down to avoid allocating
a String each time you check.
Sourcepub fn key_str_down(&self, s: &str) -> bool
pub fn key_str_down(&self, s: &str) -> bool
Return true if a Key::Character matching s is currently pressed with any Location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_down.
Sourcepub fn key_down_location(&self, key: Key, location: Location) -> bool
pub fn key_down_location(&self, key: Key, location: Location) -> bool
Return true if the key is currently pressed with location.
For a Key::Character, you can use key_str_down_location to avoid allocating
a String each time you check.
Sourcepub fn key_str_down_location(&self, s: &str, location: Location) -> bool
pub fn key_str_down_location(&self, s: &str, location: Location) -> bool
Return true if a Key::Character matching s is currently pressed with location.
This is an optimization for matching Key::Character without allocating a String.
If you are matching a Key::Named then use key_down.
Sourcepub fn code_down(&self, code: Code) -> bool
pub fn code_down(&self, code: Code) -> bool
Return true if the code is currently pressed with any Location.
Sourcepub fn clear_frame(&mut self)
pub fn clear_frame(&mut self)
Clear the per-frame state to prepare for a new frame.
Sourcepub fn process_keyboard_event(&mut self, event: KeyboardEvent)
pub fn process_keyboard_event(&mut self, event: KeyboardEvent)
Update the state based on the given pointer event.
Only events from the primary pointer are processed. Press and release
events update the just_pressed, just_released, and down states.
Trait Implementations§
Source§impl Clone for KeyboardState
impl Clone for KeyboardState
Source§fn clone(&self) -> KeyboardState
fn clone(&self) -> KeyboardState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more