diff --git a/src/gui.rs b/src/gui.rs index 640ecd5..8c2e7be 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,7 +1,6 @@ use iced::widget::{button, column, text}; use iced::executor; use iced::keyboard; -use iced::event; use iced::subscription; use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command}; @@ -138,9 +137,8 @@ impl Application for Main { } }, Message::EventOccurred(event) => { - eprintln!("{:?}", event); match event { - iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ // TODO key released + iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ key_code, modifiers: _, .. @@ -148,6 +146,15 @@ impl Application for Main { self.keys_down.push(key_code); self.keys_down.dedup(); }, + iced::event::Event::Keyboard(keyboard::Event::KeyReleased{ + key_code, + .. + }) => { + match self.keys_down.iter().position(|x| *x == key_code) { + Some(idx) => { self.keys_down.remove(idx); }, + None => {}, + }; + }, _ => {}, } }, diff --git a/src/stream.rs b/src/stream.rs index bfee73e..5c72e77 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -226,7 +226,7 @@ impl OutputStream for OutputStreamFormatted { } fn sprintf(x: &String, v: Vec) -> Vec { - let mut reg = Handlebars::new(); + let reg = Handlebars::new(); return reg.render_template(x, &json!({ "VALUE": v.iter().collect::(), "ms_since_epoch": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),