aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2025-02-09 08:39:01 +0300
committerGitHub <noreply@github.com>2025-02-09 08:39:01 +0300
commit6fefa78eafa43f13998439cb9eaf15bc0441f004 (patch)
tree95d4b022542709fceca6bec51c011bef606dc042
parent3c7a323ef5b0cb0631f857a96d7d874008ee515a (diff)
downloadr-alacritty-6fefa78eafa43f13998439cb9eaf15bc0441f004.tar.gz
r-alacritty-6fefa78eafa43f13998439cb9eaf15bc0441f004.tar.bz2
r-alacritty-6fefa78eafa43f13998439cb9eaf15bc0441f004.zip
Don't report unshifted key when Shift was not pressed
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/input/keyboard.rs21
2 files changed, 13 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32934a17..ba177deb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its
- Crash when OpenGL context resets
- Modifiers being out of sync for fast/synthetic input on X11
- Child process creation failing while inside a deleted directory
+- Shifted key reported without a shift when using kitty keyboard protocol
## 0.15.0
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs
index af9bfbb2..417f599b 100644
--- a/alacritty/src/input/keyboard.rs
+++ b/alacritty/src/input/keyboard.rs
@@ -342,18 +342,21 @@ impl SequenceBuilder {
};
if character.chars().count() == 1 {
- let character = character.chars().next().unwrap();
- let base_character = character.to_lowercase().next().unwrap();
+ let shift = self.modifiers.contains(SequenceModifiers::SHIFT);
- let alternate_key_code = u32::from(character);
- let mut unicode_key_code = u32::from(base_character);
+ let ch = character.chars().next().unwrap();
+ let unshifted_ch = if shift { ch.to_lowercase().next().unwrap() } else { ch };
+
+ let alternate_key_code = u32::from(ch);
+ let mut unicode_key_code = u32::from(unshifted_ch);
// Try to get the base for keys which change based on modifier, like `1` for `!`.
- match key.key_without_modifiers().as_ref() {
- Key::Character(unmodded) if alternate_key_code == unicode_key_code => {
- unicode_key_code = u32::from(unmodded.chars().next().unwrap_or(base_character));
- },
- _ => (),
+ //
+ // However it should only be performed when `SHIFT` is pressed.
+ if shift && alternate_key_code == unicode_key_code {
+ if let Key::Character(unmodded) = key.key_without_modifiers().as_ref() {
+ unicode_key_code = u32::from(unmodded.chars().next().unwrap_or(unshifted_ch));
+ }
}
// NOTE: Base layouts are ignored, since winit doesn't expose this information