From 8c5cb843c95bb9d2ea39ffbf3d5c7dfcc307f673 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Fri, 2 Aug 2024 12:27:58 +0200 Subject: [PATCH] fix: only handle key pressed events and not released ones --- CHANGELOG.md | 4 ++++ src/interactive/mod.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df35f7..cda7235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Only handle key pressed events and ignore released events. + ## [0.21.1] - 2024-07-30 ### Changed diff --git a/src/interactive/mod.rs b/src/interactive/mod.rs index 79c40ff..d4325ae 100644 --- a/src/interactive/mod.rs +++ b/src/interactive/mod.rs @@ -1,6 +1,8 @@ use std::time::{Duration, Instant}; -use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEventKind}; +use crossterm::event::{ + Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseButton, MouseEventKind, +}; use ratatui::backend::{Backend, CrosstermBackend}; use ratatui::layout::{Alignment, Position, Rect}; use ratatui::text::Span; @@ -106,6 +108,7 @@ where let timeout = debounce.map_or(INTERVAL, |start| DEBOUNCE.saturating_sub(start.elapsed())); if crossterm::event::poll(timeout)? { let refresh = match crossterm::event::read()? { + Event::Key(key) if !matches!(key.kind, KeyEventKind::Press) => Refresh::Skip, Event::Key(key) => app.on_key(key)?, Event::Mouse(mouse) => match mouse.kind { MouseEventKind::Down(MouseButton::Left) => {