Guide API
Skip to main content

is_alt_hotkey

Function is_alt_hotkey 

Source
pub fn is_alt_hotkey(ke: &KeyEvent, hot: char) -> bool
Expand description

Test whether a key event is the Alt-accelerator for a given hotkey char.

Together with is_plain_hotkey (and optionally ctrl_to_arrow for WordStar nav pre-processing), these predicates implement hotkey-accelerator matching for buttons, clusters, and labels. Callers compose them with the phase/focus gate.

Returns true iff:

  • ke.modifiers.alt is set, and
  • ke.key is Key::Char(c) where c matches hot case-insensitively.

Any Alt+Char is accepted case-insensitively; in practice hotkeys are always letters or digits. Only alt is required; shift and ctrl are not checked.

§Turbo Vision heritage

Replaces the event.keyDown.keyCode == getAltCode(c) accelerator idiom (tbutton.cpp, tcluster.cpp, tlabel.cpp). The original getAltCode was a whitelist of A–Z, 0–9, -, =; this predicate is deliberately broader. The Alt-Space special case is dropped.