Skip to content

Commit

Permalink
Since 0.26, crossterm detects key release events on Windows. As a con…
Browse files Browse the repository at this point in the history
…sequence, key events were handled twice, one for key press and one for key release. (#78)

This fixes the issue by ignoring events when the type is not a key press.
See relevant issue on crossterm:
crossterm-rs/crossterm#797
  • Loading branch information
programingjd authored Jul 30, 2023
1 parent e6e7a82 commit 4536146
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::{error::Error, fs::File, process};

use arboard::Clipboard;
use crossterm::event::{self, Event};
use crossterm::event::{self, Event, KeyEventKind};

use crate::buffer::AsyncBuffer;
use crate::decoder::Encoding;
Expand Down Expand Up @@ -219,8 +219,10 @@ impl Application {
let event = event::read()?;
match event {
Event::Key(key) => {
self.labels.notification.clear();
return input::handle_key_input(self, key);
if key.kind == KeyEventKind::Press {
self.labels.notification.clear();
return input::handle_key_input(self, key);
}
}
Event::Mouse(mouse) => {
self.labels.notification.clear();
Expand Down

0 comments on commit 4536146

Please sign in to comment.