Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): avoid dupe key events on windows #7809

Merged
merged 1 commit into from Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/turborepo-ui/src/tui/input.rs
Expand Up @@ -21,6 +21,13 @@ pub fn input(interact: bool) -> Result<Option<Event>, Error> {

/// Converts a crostterm key event into a TUI interaction event
fn translate_key_event(interact: bool, key_event: KeyEvent) -> Option<Event> {
// On Windows events for releasing a key are produced
// We skip these to avoid emitting 2 events per key press.
// There is still a `Repeat` event for when a key is held that will pass through
// this guard.
if key_event.kind == KeyEventKind::Release {
return None;
}
match key_event.code {
KeyCode::Char('c') if key_event.modifiers == crossterm::event::KeyModifiers::CONTROL => {
ctrl_c()
Expand Down