From ea31cc63408498d7c3bfe606eb4a15d65cf8defa Mon Sep 17 00:00:00 2001 From: Dillon DuPont Date: Tue, 29 Apr 2025 11:34:18 -0700 Subject: [PATCH] added mappings for modifier keys --- libs/computer/computer/interface/models.py | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/libs/computer/computer/interface/models.py b/libs/computer/computer/interface/models.py index b586a9f7..c09a092c 100644 --- a/libs/computer/computer/interface/models.py +++ b/libs/computer/computer/interface/models.py @@ -7,6 +7,9 @@ NavigationKey = Literal['pagedown', 'pageup', 'home', 'end', 'left', 'right', 'u # Special key literals SpecialKey = Literal['enter', 'esc', 'tab', 'space', 'backspace', 'del'] +# Modifier key literals +ModifierKey = Literal['ctrl', 'shift', 'win', 'command', 'option'] + # Function key literals FunctionKey = Literal['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12'] @@ -35,6 +38,13 @@ class Key(Enum): BACKSPACE = 'backspace' DELETE = 'del' + # Modifier keys + CTRL = 'ctrl' + SHIFT = 'shift' + WIN = 'win' + COMMAND = 'command' + OPTION = 'option' + # Function keys F1 = 'f1' F2 = 'f2' @@ -73,14 +83,26 @@ class Key(Enum): 'escape': cls.ESCAPE, 'esc': cls.ESC, 'delete': cls.DELETE, - 'del': cls.DELETE + 'del': cls.DELETE, + # Modifier key mappings + 'ctrl': cls.CTRL, + 'control': cls.CTRL, + 'shift': cls.SHIFT, + 'win': cls.WIN, + 'windows': cls.WIN, + 'command': cls.COMMAND, + 'cmd': cls.COMMAND, + '⌘': cls.COMMAND, + 'option': cls.OPTION, + 'alt': cls.OPTION, + '⌥': cls.OPTION, } normalized = key.lower().strip() return key_mapping.get(normalized, key) # Combined key type -KeyType = Union[Key, NavigationKey, SpecialKey, FunctionKey, str] +KeyType = Union[Key, NavigationKey, SpecialKey, ModifierKey, FunctionKey, str] class AccessibilityWindow(TypedDict): """Information about a window in the accessibility tree."""