Skip to content

Commit

Permalink
fix: kitty: correctly handle printable characters with no modifiers
Browse files Browse the repository at this point in the history
When a printable character is pressed with no modifiers, the `key.Mod`
field is set to 0. In this case, the `key.Code` field should be used to
determine the text to send to the program.

Fixes: c53a7c9 (fix: kitty: use the correct case for key text)
  • Loading branch information
aymanbagabas committed Oct 15, 2024
1 parent e8f7e58 commit 8a91939
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions kitty.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,18 @@ func parseKittyKeyboard(csi *ansi.CsiSequence) (msg Msg) {

if len(key.Text) == 0 && unicode.IsPrint(key.Code) &&
(key.Mod <= ModShift || key.Mod == ModCapsLock) {
desiredCase := unicode.ToLower
if key.Mod == ModShift || key.Mod == ModCapsLock {
desiredCase = unicode.ToUpper
}
if key.ShiftedCode != 0 {
key.Text = string(key.ShiftedCode)
if key.Mod == 0 {
key.Text = string(key.Code)
} else {
key.Text = string(desiredCase(key.Code))
desiredCase := unicode.ToLower
if key.Mod == ModShift || key.Mod == ModCapsLock {
desiredCase = unicode.ToUpper
}
if key.ShiftedCode != 0 {
key.Text = string(key.ShiftedCode)
} else {
key.Text = string(desiredCase(key.Code))
}
}
}

Expand Down

0 comments on commit 8a91939

Please sign in to comment.