use eframe::egui::{Context, Event, Key, KeyboardShortcut, Modifiers};
pub(in crate::ui::viewer) fn hotkey_pressed(ctx: &Context, key: Key) -> bool {
let via_shortcut = ctx.input_mut(|i| i.consume_shortcut(&KeyboardShortcut::new(Modifiers::COMMAND, key)));
if via_shortcut {
return true;
}
let via_combo = ctx.input_mut(|i| i.consume_key(Modifiers::COMMAND, key));
if via_combo {
return true;
}
ctx.input(|i| {
i.raw.events.iter().any(|e| {
matches!(
e,
Event::Key {
key: k,
pressed: true,
repeat: false,
modifiers,
..
} if *k == key && modifiers.command && !modifiers.alt
)
})
})
}