1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2025-04-21 18:02:37 -04:00

Don't report unshifted key when Shift was not pressed

This commit is contained in:
Kirill Chibisov 2025-02-09 08:39:01 +03:00 committed by Christian Duerr
parent 3d46335174
commit ad2ee869d1
2 changed files with 13 additions and 9 deletions

View file

@ -19,6 +19,7 @@ Notable changes to the `alacritty_terminal` crate are documented in its
- 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

View file

@ -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