Skip to main content
POST
/
browser
/
sessions
/
{id}
/
keyboard
/
press
Keyboard Press
curl --request POST \
  --url https://api.example.com/browser/sessions/{id}/keyboard/press \
  --header 'Content-Type: application/json' \
  --data '
{
  "key": "<string>",
  "selector": "<string>",
  "timeout": 123,
  "holdKeys": [
    "<string>"
  ]
}
'
{
  "success": true,
  "key": "<string>"
}

Overview

Dispatches a single keydown+keyup for a named key. Useful for submitting forms (Enter), dismissing dialogs (Escape), navigating selects (ArrowDown), or triggering shortcuts (Control+A).

Path Parameters

id
string
required
Browser session ID (UUID).

Body

key
string
required
Either a single printable character (e.g. a, 1, !) or one of the special keys:Enter, Tab, Escape, Backspace, Delete, Space, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, F1F12.Unknown names return 400.
selector
string
Optional CSS selector to click/focus before pressing.
timeout
integer
default:"5000"
How long to wait (ms) for the selector to become visible.
holdKeys
string[]
Modifier keys held for the duration of the press. Each value must be one of Shift, Control, Alt, Meta.

Example Request

curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/.../keyboard/press" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "key": "Enter" }'

Response

Success Response (200)

success
boolean
True when the key was dispatched successfully.
key
string
The key that was pressed (echoed from the request).
Example Response:
{
  "success": true,
  "key": "Enter"
}

Error Responses

StatusDescription
400Invalid body — missing key, unknown special-key name, bad modifier.
401Unauthorized — invalid or missing API key.
404Session not found, or selector did not become visible before timeout.
503The browser session is temporarily unreachable.

Notes

  • No auto-submit. press: Enter dispatches the key; any resulting form submission or navigation is the page’s doing. Wait for page state separately if you need confirmation.
  • Chord syntax is key + holdKeys[], not a single string. Consistent with /mouse/click.
  • Holding keys across multiple presses requires calling press for each key; modifier state is released after each call.

Supported editor chords

The following Ctrl/Meta chords execute their editor command in addition to firing the keydown/keyup events, so you can select, copy, paste, and undo in text fields just like a user would:
ChordAction
Ctrl/Meta + ASelect all
Ctrl/Meta + CCopy selection
Ctrl/Meta + XCut selection
Ctrl/Meta + VPaste
Ctrl/Meta + ZUndo
Ctrl/Meta + Shift + ZRedo
Ctrl/Meta + YRedo (Windows-style)
Other Ctrl/Meta chords still dispatch the keydown event with the modifier set (page listeners see ctrlKey: true) but don’t trigger browser-chrome accelerators like new-tab or close-tab.