Skip to content

press_key

Kelly Ferrone edited this page Sep 12, 2026 · 6 revisions

press_key

Press a named key, at an element or wherever focus currently is.

MCP tool press_key
HTTP POST /browser/press-key

For Tab, Escape, Enter, arrows and similar. Known keys: add, alt, arrow_down, arrow_left, arrow_right, arrow_up, back_space, backspace, cancel, clear, command, control, decimal, delete, divide, down, end, enter, equals, escape, f1, f10, f11, f12, f2, f3, f4, f5, f6, f7, f8, f9, help, home, insert, left, left_alt, left_command, left_control, left_meta, left_option, left_shift, meta, multiply, null, numpad0, numpad1, numpad2, numpad3, numpad4, numpad5, numpad6, numpad7, numpad8, numpad9, page_down, page_up, pause, return, right, right_alt, right_control, right_meta, right_option, right_shift, semicolon, separator, shift, space, subtract, tab, up, zenkaku_hankaku.

Not a reliable way to scroll - page_down only moves the page when focus happens to be on the scrollable container. Use execute_script to scroll.

To aim the key at an element, pass xpath or css; with neither, it goes wherever focus already is.

Parameters

Name Type Required Default Notes
key string yes
session_id string yes over HTTP The session_id returned by /browser/open. Required here.
xpath string no
css string no
url string no
wait_timeout integer no 30

Returns

Field Type Notes
key string The key that was sent.
url string Current URL after the action.
title string Page title after the action.

Errors

Status Means
400 The request cannot succeed as sent — a missing field, a value that was rejected, or a locator that matched nothing before the wait ran out. Do not retry it unchanged.
401 Missing or wrong bearer token.
404 No such browser session. It ended, the Grid reaped it, or the id was never real. Open a new one and retry.
500 Something failed that this server did not expect.
503 The Grid could not serve this — unreachable, or no free slot for a new browser. Worth retrying after a wait.

Over MCP the same failures arrive as a tool error.

Example

MCP

press_key(key="…")

HTTP

curl -X POST $SELENIUM_FLOW/browser/press-key \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "session_id": "…",
    "key": "…"
  }'

← All actions · Installing · Deployment

Clone this wiki locally