From fe2df1b5b22b573e74ab967b832566f4f5d549e7 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 13 Jul 2023 15:43:19 +0000 Subject: Prefer logical key for named keys Some keyboard layouts have named logical keys via shift combinations of some sorts. So prefer them. Fixes #7076. --- alacritty/src/input.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index f43d9ec7..19996c72 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -23,7 +23,7 @@ use winit::event::{ use winit::event_loop::EventLoopWindowTarget; #[cfg(target_os = "macos")] use winit::keyboard::ModifiersKeyState; -use winit::keyboard::ModifiersState; +use winit::keyboard::{Key, ModifiersState}; #[cfg(target_os = "macos")] use winit::platform::macos::{EventLoopWindowTargetExtMacOS, OptionAsAlt}; use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; @@ -1050,9 +1050,17 @@ impl> Processor { for i in 0..self.ctx.config().key_bindings().len() { let binding = &self.ctx.config().key_bindings()[i]; - let key = match (&binding.trigger, &key.key_without_modifiers()) { + // When the logical key is some named key, use it, otherwise fallback to + // key without modifiers to account for bindings. + let logical_key = if matches!(key.logical_key, Key::Character(_)) { + key.key_without_modifiers() + } else { + key.logical_key.clone() + }; + + let key = match (&binding.trigger, logical_key) { (BindingKey::Scancode(_), _) => BindingKey::Scancode(key.physical_key), - (_, code) => BindingKey::Keycode { key: code.clone(), location: key.location }, + (_, code) => BindingKey::Keycode { key: code, location: key.location }, }; if binding.is_triggered_by(mode, mods, &key) { -- cgit