Skip to content

Commit 73ef8e1

Browse files
authored
Merge pull request #224 from replydev/fix/double_input_windows
Fix double input on Windows
2 parents 8fb0d0f + 1e51d39 commit 73ef8e1

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cotp"
3-
version = "1.2.3"
3+
version = "1.2.4"
44
authors = ["replydev <[email protected]>"]
55
edition = "2021"
66
description = "Trustworthy, encrypted, command-line TOTP/HOTP authenticator app with import functionality."

src/interface/event.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::mpsc;
22
use std::thread;
33
use std::time::{Duration, Instant};
44

5-
use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, MouseEvent};
5+
use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, KeyEventKind, MouseEvent};
66

77
use crate::interface::app::AppResult;
88

@@ -50,7 +50,15 @@ impl EventHandler {
5050

5151
if event::poll(timeout).expect("no events available") {
5252
match event::read().expect("unable to read event") {
53-
CrosstermEvent::Key(e) => sender.send(Event::Key(e)),
53+
CrosstermEvent::Key(e) => {
54+
// Workaround to fix double input on Windows
55+
// Please check https://github.com/crossterm-rs/crossterm/issues/752
56+
if e.kind == KeyEventKind::Press {
57+
sender.send(Event::Key(e))
58+
} else {
59+
Ok(())
60+
}
61+
}
5462
CrosstermEvent::Mouse(e) => sender.send(Event::Mouse(e)),
5563
CrosstermEvent::Resize(w, h) => sender.send(Event::Resize(w, h)),
5664
CrosstermEvent::FocusGained => sender.send(Event::FocusGained()),

0 commit comments

Comments
 (0)