use crossterm::event::KeyCode; use rustc_hash::FxHashSet; #[derive(Debug, Default, Clone)] pub struct InputManager { pressed_keys: FxHashSet, } impl InputManager { pub fn new() -> Self { Self { pressed_keys: FxHashSet::default(), } } pub fn press_key(&mut self, key_code: KeyCode) { self.pressed_keys.insert(key_code); } pub fn reset_next_frame(&mut self) { self.pressed_keys.clear(); } pub fn is_key_pressed_this_frame(&self, key_code: KeyCode) -> bool { self.pressed_keys.contains(&key_code) } }