Skip to content

Commit

Permalink
Merge pull request #224 from replydev/fix/double_input_windows
Browse files Browse the repository at this point in the history
Fix double input on Windows
  • Loading branch information
replydev authored May 12, 2023
2 parents 8fb0d0f + 1e51d39 commit 73ef8e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cotp"
version = "1.2.3"
version = "1.2.4"
authors = ["replydev <[email protected]>"]
edition = "2021"
description = "Trustworthy, encrypted, command-line TOTP/HOTP authenticator app with import functionality."
Expand Down
12 changes: 10 additions & 2 deletions src/interface/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::mpsc;
use std::thread;
use std::time::{Duration, Instant};

use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, MouseEvent};
use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, KeyEventKind, MouseEvent};

use crate::interface::app::AppResult;

Expand Down Expand Up @@ -50,7 +50,15 @@ impl EventHandler {

if event::poll(timeout).expect("no events available") {
match event::read().expect("unable to read event") {
CrosstermEvent::Key(e) => sender.send(Event::Key(e)),
CrosstermEvent::Key(e) => {
// Workaround to fix double input on Windows
// Please check https://github.com/crossterm-rs/crossterm/issues/752
if e.kind == KeyEventKind::Press {
sender.send(Event::Key(e))
} else {
Ok(())
}
}
CrosstermEvent::Mouse(e) => sender.send(Event::Mouse(e)),
CrosstermEvent::Resize(w, h) => sender.send(Event::Resize(w, h)),
CrosstermEvent::FocusGained => sender.send(Event::FocusGained()),
Expand Down

0 comments on commit 73ef8e1

Please sign in to comment.