Skip to content

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

add instant selection with numbers

Reagan Hsu7e2d4f5dbd27
diff --git a/browser_use/init_cmd.py b/browser_use/init_cmd.py
index 6065cda49..596685165 100644
--- a/browser_use/init_cmd.py
+++ b/browser_use/init_cmd.py
@@ -140,12 +140,26 @@ def main(
for name, info in INIT_TEMPLATES.items()
]
- template = RawlistPrompt(
+ # Create the prompt
+ prompt = RawlistPrompt(
message='Select a template:',
choices=choices,
default='default',
style=inquirer_style,
- ).execute()
+ )
+
+ # Add custom keybindings for instant selection with number keys
+ template_list = list(INIT_TEMPLATES.keys())
+
+ # Register number keys 1-3 for instant selection
+ for i, template_name in enumerate(template_list, 1):
+
+ @prompt.register_kb(str(i))
+ def _(event, name=template_name):
+ """Instantly select template when number key is pressed"""
+ event.app.exit(result=name)
+
+ template = prompt.execute()
# Handle user cancellation (Ctrl+C)
if template is None: