aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-07-31 21:06:04 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-07-31 21:06:04 -0400
commit130ddd81170fed904218381d7182c36fd78e9d6d (patch)
tree465a44a447a8875270fca4b50a6a39a90466ad0b /src
parent15c97f12e9c78da55ae7663e9f653cb0bc98d289 (diff)
Fix just pressedv0.4.1
Diffstat (limited to 'src')
-rw-r--r--src/input/resources.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/input/resources.rs b/src/input/resources.rs
index ba2f6dd..a733984 100644
--- a/src/input/resources.rs
+++ b/src/input/resources.rs
@@ -1,4 +1,4 @@
-use bevy::{prelude:: *, utils::HashSet};
+use bevy::{prelude::*, utils::HashSet};
use crossterm::event::{Event, KeyCode};
use std::sync::{Arc, Mutex};
@@ -28,8 +28,10 @@ impl TerminalInput {
/// Sets given key to pressed
pub(super) fn press(&mut self, code: KeyCode) {
- self.pressed_keys.insert(code);
- self.just_pressed_keys.insert(code);
+ if !self.pressed_keys.contains(&code) {
+ self.pressed_keys.insert(code);
+ self.just_pressed_keys.insert(code);
+ }
}
/// Sets given key to released and removes pressed state
@@ -42,7 +44,7 @@ impl TerminalInput {
pub(super) fn clear_just_released(&mut self) {
self.just_released_keys.clear();
}
-
+
/// Clears all just pressed keys
pub(super) fn clear_just_pressed(&mut self) {
self.just_pressed_keys.clear();