from __future__ import annotations HOTKEY_MODIFIERS = { "shift", "ctrl", "control", "alt", "mod1", "super", "mod4", "cmd", "command", } def split_hotkey(hotkey: str) -> tuple[list[str], str]: parts = [p.strip() for p in hotkey.split("+") if p.strip()] modifiers: list[str] = [] key_part = "" for part in parts: low = part.lower() if low in HOTKEY_MODIFIERS: modifiers.append(low) continue if key_part: raise ValueError("must include exactly one non-modifier key") key_part = part if not key_part: raise ValueError("missing key") return modifiers, key_part