Skip to main content

Module shortcut

Module shortcut 

Source
Expand description

Keyboard shortcuts as Bern writes them: the modifiers cmd (the primary modifier: Command on Apple systems, Control elsewhere), ctrl, alt and shift, then one key, joined by +, such as "cmd+k" or "space". Declarations write them as literals, which the compiler normalizes; a shortcut that follows state is a text in the same form, which engines normalize with parse_shortcut before they keep it, and every runtime reads by the same rules.

Constants§

SHORTCUT_KEYS
Keys a shortcut may name besides a single printable character.

Functions§

parse_shortcut
Normalize a keyboard shortcut: modifiers cmd, ctrl, alt and shift in that order, then one key: a printable character in lower case or one of SHORTCUT_KEYS. Case and spaces around the parts do not matter, so "Shift + Cmd + K" is "cmd+shift+k".
same_keys
Whether two shortcuts are pressed with the same keys on a system that is (apple) or is not an Apple one: elsewhere cmd is Control, so cmd+k and ctrl+k are one shortcut there. Texts that are no shortcut are the same as nothing else.