pub struct KeyBuf { /* private fields */ }Expand description
A container for Window-based keyboard input events.
NOTE: Keys pressed and released during a single update (is that possible, really?) will show as both released and pressed.
Implementations§
source§impl KeyBuf
impl KeyBuf
sourcepub fn any_pressed(&self) -> bool
pub fn any_pressed(&self) -> bool
Returns true if any keys have been pressed since the last frame.
sourcepub fn any_released(&self) -> bool
pub fn any_released(&self) -> bool
Returns true if any keys have been released since the last frame.
sourcepub fn chars(&self) -> impl Iterator<Item = char> + '_
pub fn chars(&self) -> impl Iterator<Item = char> + '_
Returns an iterator of characters typed since the last frame.
sourcepub fn handle_event(&mut self, event: &Event<()>) -> bool
pub fn handle_event(&mut self, event: &Event<()>) -> bool
Handles a single event.
sourcepub fn is_down(&self, key: KeyCode) -> bool
pub fn is_down(&self, key: KeyCode) -> bool
Returns true if the given key has been pressed since the last frame or held for multiple
frames.
sourcepub fn is_held(&self, key: KeyCode) -> bool
pub fn is_held(&self, key: KeyCode) -> bool
Returns true if the given key has been pressed for multiple frames.
sourcepub fn is_pressed(&self, key: KeyCode) -> bool
pub fn is_pressed(&self, key: KeyCode) -> bool
Returns true if the given key has been pressed since the last frame.
sourcepub fn is_released(&self, key: KeyCode) -> bool
pub fn is_released(&self, key: KeyCode) -> bool
Returns true if the given key has been released since the last frame.
sourcepub fn held(&self) -> impl Iterator<Item = KeyCode> + '_
pub fn held(&self) -> impl Iterator<Item = KeyCode> + '_
Returns an iterator of keys pressed for multiple frames.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for KeyBuf
impl Send for KeyBuf
impl Sync for KeyBuf
impl Unpin for KeyBuf
impl UnwindSafe for KeyBuf
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.