Struct ggez::input::keyboard::KeyboardContext
source · pub struct KeyboardContext { /* private fields */ }
Expand description
Tracks held down keyboard keys, active keyboard modifiers, and figures out if the system is sending repeat keystrokes.
Implementations§
source§impl KeyboardContext
impl KeyboardContext
sourcepub fn is_key_pressed(&self, key: KeyCode) -> bool
pub fn is_key_pressed(&self, key: KeyCode) -> bool
Checks if a key is currently pressed down.
sourcepub fn is_key_just_pressed(&self, key: KeyCode) -> bool
pub fn is_key_just_pressed(&self, key: KeyCode) -> bool
Checks if a key has been pressed down this frame.
sourcepub fn is_key_just_released(&self, key: KeyCode) -> bool
pub fn is_key_just_released(&self, key: KeyCode) -> bool
Checks if a key has been released this frame.
sourcepub fn is_scancode_pressed(&self, code: ScanCode) -> bool
pub fn is_scancode_pressed(&self, code: ScanCode) -> bool
Checks if a key with the corresponding scan code is currently pressed down.
sourcepub fn is_scancode_just_pressed(&self, code: ScanCode) -> bool
pub fn is_scancode_just_pressed(&self, code: ScanCode) -> bool
Checks if a key with the corresponding scan code has been pressed down this frame.
sourcepub fn is_scancode_just_released(&self, code: ScanCode) -> bool
pub fn is_scancode_just_released(&self, code: ScanCode) -> bool
Checks if a key with the corresponding scan code has been released this frame.
sourcepub fn is_key_repeated(&self) -> bool
pub fn is_key_repeated(&self) -> bool
Checks if the last keystroke sent by the system is repeated, like when a key is held down for a period of time.
sourcepub fn pressed_keys(&self) -> &HashSet<KeyCode>
pub fn pressed_keys(&self) -> &HashSet<KeyCode>
Returns a reference to the set of currently pressed keys.
sourcepub fn pressed_scancodes(&self) -> &HashSet<ScanCode>
pub fn pressed_scancodes(&self) -> &HashSet<ScanCode>
Returns a reference to the set of currently pressed scancodes.
sourcepub fn is_mod_active(&self, keymods: KeyMods) -> bool
pub fn is_mod_active(&self, keymods: KeyMods) -> bool
Checks if keyboard modifier (or several) is active.
sourcepub fn active_mods(&self) -> KeyMods
pub fn active_mods(&self) -> KeyMods
Returns currently active keyboard modifiers.
sourcepub fn save_keyboard_state(&mut self)
pub fn save_keyboard_state(&mut self)
Copies the current state of the keyboard into the context. If you are writing your own event loop
you need to call this at the end of every update in order to use the functions is_key_just_pressed
and is_key_just_released
. Otherwise this is handled for you.
sourcepub fn set_modifiers(&mut self, keymods: KeyMods)
pub fn set_modifiers(&mut self, keymods: KeyMods)
Set the keyboard active modifiers Really useful only if you are writing your own event loop
Trait Implementations§
source§impl Clone for KeyboardContext
impl Clone for KeyboardContext
source§fn clone(&self) -> KeyboardContext
fn clone(&self) -> KeyboardContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more