press_key
Simulates user keyboard input in Java Swing apps, sending keys, shortcuts, or sequences to the focused component or a specified ref, and can answer modal dialogs.
Instructions
Press keys like a user: "Enter", "Escape", "Tab", "Shift+Tab", "Up", "F5", "Ctrl+S", "Alt+F4", or several separated by spaces ("Tab Tab Enter"). Keys go to the component that has the keyboard focus (marked "focused" in the snapshot), or to ref after focusing it, so key bindings, menu shortcuts, the default button and focus traversal work as for a user. Without ref, keys go to the open modal dialog if there is one. The application window does not need to be in front. The result says where the focus is afterwards. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"key": "<key>"
},
"name": "press_key"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key or chord, e.g. Enter, Escape, Ctrl+S, Shift+Tab, F2; several separated by spaces | |
| ref | No | Component to focus first (default: the focused component) | |
| mode | No | keys (default): key events inside the application; os: real keyboard through the operating system (brings the window to the front) | |
| dialog | No | Answer the modal dialog this action opens with this button (text, or ok/yes/no/cancel); its message is reported. An error if no dialog opens within 3 s | |
| timeoutMs | No | How long to wait for the component to become usable (default 10000) |