normalize_shortcut
Validate a shortcut spec and return it in canonical order.
from plexora.api import normalize_shortcutAlso available as plexora.api.plugin.normalize_shortcut.
normalize_shortcut(spec: str, owner: str = '') -> strThe spec is written "mod+shift+e": modifiers from SHORTCUT_MODIFIERS
in any order, then exactly one key. It comes back with the modifiers
sorted into SHORTCUT_MODIFIERS order and lowercased, so two specs that
mean the same chord compare equal.
Plugin.shortcut and NavItem.shortcut already call this; call it
directly only when building a shortcut spec some other way.
At least one modifier is required -- a bare letter would be a global shortcut competing with the ones plugins already bind against the canvas while their own panel is open, and the tool that opens on a keystroke must never depend on which panel happens to be listening.
Parameters
specstrrequiredThe shortcut, e.g. "mod+e" or "mod+shift+e".
ownerstrdefault ''A name for spec, used only in error
messages -- typically the plugin or nav item it belongs to.
Returns
strspec, with its modifiers sorted and lowercased.
Raises
ValueErrorIf spec has no modifier, an unknown modifier, a
repeated modifier, an invalid key, or a key that the modifier
combination reserves for the browser (such as "mod+t").