From 04c05ae6a1406e1c61180c799eb9d13fcb5b659c Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 29 Aug 2024 09:58:59 -0600 Subject: [PATCH] fix(menu): Ignore Key::Character case when matching KeyBind --- src/widget/menu/key_bind.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widget/menu/key_bind.rs b/src/widget/menu/key_bind.rs index 4afc7552..a6934ff1 100644 --- a/src/widget/menu/key_bind.rs +++ b/src/widget/menu/key_bind.rs @@ -38,7 +38,12 @@ impl KeyBind { /// /// * `bool` - `true` if the key and modifiers match the `KeyBind`, `false` otherwise. pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool { - key == &self.key + let key_eq = match (key, &self.key) { + // CapsLock and Shift change the case of Key::Character, so we compare these in a case insensitive way + (Key::Character(a), Key::Character(b)) => a.eq_ignore_ascii_case(&b), + (a, b) => a.eq(b), + }; + key_eq && modifiers.logo() == self.modifiers.contains(&Modifier::Super) && modifiers.control() == self.modifiers.contains(&Modifier::Ctrl) && modifiers.alt() == self.modifiers.contains(&Modifier::Alt)