Skip to content

Commit

Permalink
fix: only handle key pressed events and not released ones
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Aug 2, 2024
1 parent 9c3ff71 commit 8c5cb84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/interactive/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 8c5cb84

Please sign in to comment.