Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

patch key normalization issue (#793)

Sarina Li9f970a34977f
diff --git a/libs/python/computer-server/computer_server/main.py b/libs/python/computer-server/computer_server/main.py
index ecde75ae59..e5a9c9d4a8 100644
--- a/libs/python/computer-server/computer_server/main.py
+++ b/libs/python/computer-server/computer_server/main.py
@@ -616,10 +616,27 @@ async def agent_response_endpoint(
await self._auto.move_cursor(x, y)
async def keypress(self, keys: Union[List[str], str]) -> None:
+ from computer.interface.models import Key
+
+ def normalize_key(key: str) -> str:
+ """Normalize key name using SDK's Key.from_string()."""
+ result = Key.from_string(key)
+ if isinstance(result, Key):
+ # SDK mapped it to a Key enum, use its value
+ return result.value
+ else:
+ # SDK didn't map it - lowercase for pynput compatibility
+ # (pynput uses lowercase: Key.tab, Key.space, etc.)
+ return key.lower() if len(key) > 1 else key
+
if isinstance(keys, str):
parts = keys.replace("-", "+").split("+") if len(keys) > 1 else [keys]
else:
parts = keys
+
+ # Normalize all key parts using SDK's Key mapping
+ parts = [normalize_key(p) for p in parts]
+
if len(parts) == 1:
await self._auto.press_key(parts[0])
else: