Skip to content

Commit bc61af0

Browse files
committed
Keys fix
1 parent 3e1015f commit bc61af0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

interpreter/computer_use/tools/computer.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,21 @@ async def __call__(
162162
if action == "key":
163163
if platform.system() == "Darwin": # Check if we're on macOS
164164
text = text.replace("super+", "command+")
165-
keys = text.split("+")
165+
166+
# Normalize key names
167+
def normalize_key(key):
168+
key = key.lower().replace("_", "")
169+
key_map = {
170+
"pagedown": "pgdn",
171+
"pageup": "pgup",
172+
"enter": "return",
173+
"return": "enter",
174+
# Add more mappings as needed
175+
}
176+
return key_map.get(key, key)
177+
178+
keys = [normalize_key(k) for k in text.split("+")]
179+
166180
if len(keys) > 1:
167181
if "darwin" in platform.system().lower():
168182
# Use AppleScript for hotkey on macOS
@@ -181,7 +195,7 @@ async def __call__(
181195
else:
182196
pyautogui.hotkey(*keys)
183197
else:
184-
pyautogui.press(text)
198+
pyautogui.press(keys[0])
185199
elif action == "type":
186200
pyautogui.write(text, interval=TYPING_DELAY_MS / 1000)
187201

0 commit comments

Comments
 (0)