summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-06-05 21:31:46 +0200
committerHampusM <hampus@hampusmat.com>2026-06-05 21:31:46 +0200
commitf587ceeda7b05f7eca4d5c06c6509cd529262cf0 (patch)
treec551edfaf37b83cf162835389b8ddf2ca76fbd02 /engine
parent7959b51dbb2dbe13297a1ee0702eb4831348703e (diff)
feat(engine): add Keyboard::new_key_states fn
Diffstat (limited to 'engine')
-rw-r--r--engine/src/windowing/keyboard.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/engine/src/windowing/keyboard.rs b/engine/src/windowing/keyboard.rs
index 0bb70a7..5a31e7c 100644
--- a/engine/src/windowing/keyboard.rs
+++ b/engine/src/windowing/keyboard.rs
@@ -38,6 +38,19 @@ impl Keyboard
self.get_key_state(key) == KeyState::Released
}
+ /// Returns a iterator of key & key state pairs where each of the keys have a
+ /// different state than they had the previous frame.
+ pub fn new_key_states(&self) -> impl Iterator<Item = (Key, KeyState)> + use<'_>
+ {
+ self.map.iter().filter_map(|(key, key_data)| {
+ if key_data.curr_state == key_data.previous_state {
+ return None;
+ }
+
+ Some((*key, key_data.curr_state))
+ })
+ }
+
#[must_use]
pub fn get_key_state(&self, key: Key) -> KeyState
{