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>"
]
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/keyboard/press"
payload = {
"key": "<string>",
"selector": "<string>",
"timeout": 123,
"holdKeys": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({key: '<string>', selector: '<string>', timeout: 123, holdKeys: ['<string>']})
};
fetch('https://api.example.com/browser/sessions/{id}/keyboard/press', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/keyboard/press",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'key' => '<string>',
'selector' => '<string>',
'timeout' => 123,
'holdKeys' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/keyboard/press"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/keyboard/press")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/keyboard/press")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"key": "<string>"
}Browser Sessions
Keyboard Press
Press a single key (printable char or special key name) with optional modifier hold.
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>"
]
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/keyboard/press"
payload = {
"key": "<string>",
"selector": "<string>",
"timeout": 123,
"holdKeys": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({key: '<string>', selector: '<string>', timeout: 123, holdKeys: ['<string>']})
};
fetch('https://api.example.com/browser/sessions/{id}/keyboard/press', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/keyboard/press",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'key' => '<string>',
'selector' => '<string>',
'timeout' => 123,
'holdKeys' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/keyboard/press"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/keyboard/press")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/keyboard/press")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"selector\": \"<string>\",\n \"timeout\": 123,\n \"holdKeys\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"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
string
required
Browser session ID (UUID).
Body
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, F1–F12.Unknown names return 400.string
Optional CSS selector to click/focus before pressing.
integer
default:"5000"
How long to wait (ms) for the selector to become visible.
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" }'
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": "a", "holdKeys": ["Control"] }'
await fetch(
"https://api.scrapengine.io/api/v1/browser/sessions/.../keyboard/press",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ key: "Enter", holdKeys: ["Shift"] }),
},
);
import requests
requests.post(
"https://api.scrapengine.io/api/v1/browser/sessions/.../keyboard/press",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"key": "Enter", "holdKeys": ["Shift"]},
)
Response
Success Response (200)
boolean
True when the key was dispatched successfully.
string
The key that was pressed (echoed from the request).
{
"success": true,
"key": "Enter"
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — missing key, unknown special-key name, bad modifier. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found, or selector did not become visible before timeout. |
503 | The browser session is temporarily unreachable. |
Notes
- No auto-submit.
press: Enterdispatches 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
pressfor each key; modifier state is released after each call.
Supported editor chords
The followingCtrl/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:
| Chord | Action |
|---|---|
Ctrl/Meta + A | Select all |
Ctrl/Meta + C | Copy selection |
Ctrl/Meta + X | Cut selection |
Ctrl/Meta + V | Paste |
Ctrl/Meta + Z | Undo |
Ctrl/Meta + Shift + Z | Redo |
Ctrl/Meta + Y | Redo (Windows-style) |
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.Was this page helpful?