Skip to content

Commit

Permalink
fix(term): input: windows: virtual key code runes
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Mar 27, 2024
1 parent 9ff3122 commit 91f6e79
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions exp/term/input/win32input.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ func parseWin32InputKeyEvent(vkc coninput.VirtualKeyCode, _ coninput.VirtualKeyC
case coninput.VK_CAPITAL:
key = Key{Sym: KeyCapsLock}
default:
k, ok := vkKeyEvent[vkc]
if !ok && isCtrl {
k = vkCtrlRune(k, r, vkc)
} else if !ok {
k = Key{Rune: r}
var ok bool
key, ok = vkKeyEvent[vkc]
if !ok {
if isCtrl {
key = vkCtrlRune(key, r, vkc)
} else {
key = Key{Rune: r}
}
}
key = k
}

if isCtrl {
Expand Down Expand Up @@ -227,5 +229,12 @@ func vkCtrlRune(k Key, r rune, kc coninput.VirtualKeyCode) Key {
k.Rune = '['
}

// https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
if k.Rune == 0 &&
(kc >= 0x30 && kc <= 0x39) ||
(kc >= 0x41 && kc <= 0x5a) {
k.Rune = rune(kc)
}

return k
}

0 comments on commit 91f6e79

Please sign in to comment.