From d3df8fe7ef7deea0fc00cfbe20be1f4dccd31fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 15 Feb 2023 23:52:08 +0200 Subject: [PATCH] fix: Fix user_input example double key press registered on windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 朕与将军解战袍 <72246322+a1393323447@users.noreply.github.com> --- examples/user_input.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/user_input.rs b/examples/user_input.rs index 330d5026..911ccf15 100644 --- a/examples/user_input.rs +++ b/examples/user_input.rs @@ -10,7 +10,7 @@ /// * Pressing Enter pushes the current input in the history of previous /// messages use crossterm::{ - event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, + event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; @@ -93,7 +93,7 @@ fn run_app(terminal: &mut Terminal, mut app: App) -> io::Result<( } _ => {} }, - InputMode::Editing => match key.code { + InputMode::Editing if key.kind == KeyEventKind::Press => match key.code { KeyCode::Enter => { app.messages.push(app.input.drain(..).collect()); } @@ -108,6 +108,7 @@ fn run_app(terminal: &mut Terminal, mut app: App) -> io::Result<( } _ => {} }, + _ => {} } } }