Skip to content

Commit

Permalink
fix(windows): coninput not handling control sequences (#1041)
Browse files Browse the repository at this point in the history
Thanks @robotastronaut for sharing their research in the Charm Discord server and for the initial fix.
In contrast to their fix, this should fully align with the key handling on Unix and fix other issues like Shift+Tab not working on Windows.
  • Loading branch information
Sculas committed Jun 21, 2024
1 parent ab28057 commit a08802e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions key_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ func readConInputs(ctx context.Context, msgsch chan<- Msg, con windows.Handle) e
}

for i := 0; i < int(e.RepeatCount); i++ {
eventKeyType := keyType(e)
var runes []rune

// Add the character only if the key type is an actual character and not a control sequence.
// This mimics the behavior in readAnsiInputs where the character is also removed.
// We don't need to handle KeySpace here. See the comment in keyType().
if eventKeyType == KeyRunes {
runes = []rune{e.Char}
}

msgs = append(msgs, KeyMsg{
Type: keyType(e),
Runes: []rune{e.Char},
Type: eventKeyType,
Runes: runes,
Alt: e.ControlKeyState.Contains(coninput.LEFT_ALT_PRESSED | coninput.RIGHT_ALT_PRESSED),
})
}
Expand Down

0 comments on commit a08802e

Please sign in to comment.