fix(menu): Ignore Key::Character case when matching KeyBind

This commit is contained in:
Jeremy Soller 2024-08-29 09:58:59 -06:00
parent 66ff28a42a
commit 04c05ae6a1

View file

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