Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix-enter

Magnus Müllere33393afcf8f
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.py
index 30305b0c9..9bd1aff1f 100644
--- a/browser_use/browser/watchdogs/default_action_watchdog.py
+++ b/browser_use/browser/watchdogs/default_action_watchdog.py
@@ -1810,6 +1810,16 @@ class DefaultActionWatchdog(BaseWatchdog):
# If it's a special key, use original logic
if normalized_keys in special_keys:
await self._dispatch_key_event(cdp_session, 'keyDown', normalized_keys)
+ # For Enter key, also dispatch a char event to trigger keypress listeners
+ if normalized_keys == 'Enter':
+ await cdp_session.cdp_client.send.Input.dispatchKeyEvent(
+ params={
+ 'type': 'char',
+ 'text': '\r',
+ 'key': 'Enter',
+ },
+ session_id=cdp_session.session_id,
+ )
await self._dispatch_key_event(cdp_session, 'keyUp', normalized_keys)
else:
# It's text (single character or string) - send each character as text input
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 06145e815..db57f14f1 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -845,7 +845,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
)
@self.registry.action(
- 'Request screenshot of current viewport. Use when: visual inspection needed, layout unclear, element positions uncertain, debugging UI issues, or verifying page state. Screenshot included in next observation.',
+ 'Request screenshot of current viewport. Use when: visual inspection needed, layout unclear, element positions uncertain, debugging UI issues, or verifying page state. Screenshot is included in the next browser_state.',
)
async def screenshot():
"""Request that a screenshot be included in the next observation"""