Skip to main content
POST
/
boxes
/
{boxId}
/
actions
/
press-key
JavaScript
import GboxSDK from "gbox-sdk";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "android" });

  // Press single key
  await box.action.pressKey({
    keys: ["Enter"]
  });

  // Press key combination
  await box.action.pressKey({
    keys: ["Control", "c"]
  });
}

main();
{
  "message": "Action executed successfully",
  "actionId": "c9bdc193-b54b-4ddb-a035-5ac0c598d32d",
  "screenshot": {
    "trace": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    },
    "before": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    },
    "after": {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
    }
  }
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer . Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Body

application/json

Press keyboard key action configuration

keys
enum<string>[]
required

This is an array of keyboard keys to press. Supports cross-platform compatibility.

Available options:
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p,
q,
r,
s,
t,
u,
v,
w,
x,
y,
z,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
f1,
f2,
f3,
f4,
f5,
f6,
f7,
f8,
f9,
f10,
f11,
f12,
control,
alt,
shift,
meta,
win,
cmd,
option,
arrowUp,
arrowDown,
arrowLeft,
arrowRight,
home,
end,
pageUp,
pageDown,
enter,
space,
tab,
escape,
backspace,
delete,
insert,
capsLock,
numLock,
scrollLock,
pause,
printScreen,
;,
=,
,,
-,
.,
/,
`,
[,
\,
],
',
numpad0,
numpad1,
numpad2,
numpad3,
numpad4,
numpad5,
numpad6,
numpad7,
numpad8,
numpad9,
numpadAdd,
numpadSubtract,
numpadMultiply,
numpadDivide,
numpadDecimal,
numpadEnter,
numpadEqual,
volumeUp,
volumeDown,
volumeMute,
mediaPlayPause,
mediaStop,
mediaNextTrack,
mediaPreviousTrack
Example:
["control", "c"]
combination
boolean
default:true

Whether to press keys as combination (simultaneously) or sequentially. When true, all keys are pressed together as a shortcut (e.g., Ctrl+C). When false, keys are pressed one by one in sequence.

Example:

true

options
Action Common Options · object

Action options. When options.screenshot is provided, ALL deprecated screenshot fields (outputFormat, presignedExpiresIn, screenshotDelay, screenshotRange, includeScreenshot) will be completely ignored.

Example:
{
"screenshot": {
"outputFormat": "base64",
"presignedExpiresIn": "30m",
"delay": "500ms",
"phases": ["before", "after"]
}
}

Response

200 - application/json

Result of an UI action execution with optional screenshots

message
string
required

message

Example:

"Action executed successfully"

actionId
string
required

Unique identifier for each action. Use this ID to locate the action and report issues.

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

screenshot
Action Result Screenshot · object

Optional screenshot data. Only present when screenshots are requested via options.screenshot.phases or deprecated fields

Example:
{
"trace": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"before": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"after": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
}