Skip to main content
Glama

Press key

press_key

Simulates a trusted keyboard key press in the browser to trigger native key events and framework shortcuts that bulk text insertion misses. Optionally focuses a selector and supports modifier keys.

Instructions

Press one key as a real keyboard event, with its native effect.

The browser produces keydown, keypress (for printable keys) and keyup, all trusted, and does what the key does: Enter submits the enclosing form or activates a focused button, Tab moves focus, Backspace deletes. Use when a framework listens for key events that type_text's bulk insert does not fire. Focuses selector first when given. Returns the key pressed and the element focused first, if any.

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

NameRequiredDescriptionDefault
keyYesKey name for named keys ('Enter', 'Tab', 'Escape', 'Backspace', 'Delete', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space', 'Home', 'End', 'PageUp', 'PageDown'), or a single character for literal keys. Example: 'Enter'
tabNoTab id from list_tabs or new_tab to act on, instead of the active tab. The active tab does not change. Omit to use the active tab. Example: 'tab_2'
selectorNoCSS selector, or a numeric id from get_interaction_tree, of the element to focus first. Omit to target whatever currently has focus. Example: '#search'
modifiersNoModifier keys held during the press, for shortcuts. Example: ['Control'] with key 'a' selects all

Output Schema

NameRequiredDescriptionDefault
keyYesThe key pressed.
targetNoElement focused first, if any.
summaryYesOne line saying what happened.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Adds substantial behavior beyond the annotations: events are trusted, keydown/keypress/keyup all fire, and the native effects (Enter submits, Tab moves focus, Backspace deletes) are enumerated. It also states that the selector is focused first and that the key plus first focused element are returned, which the annotations do not convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action, then rationale and side effects. Slightly verbose in the mid-section about event sequence, but each sentence carries useful information; nothing is padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists so return values need not be explained in depth, and the description still notes what is returned. For a 4-parameter, non-idempotent interaction tool with openWorldHint, the native-effect and event-trust details make it complete enough to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so every parameter is already documented including key names, tab targeting, selector focus, and modifier examples. The description only restates the selector-focusing behavior, adding no syntax or format detail beyond the schema, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Press one key as a real keyboard event, with its native effect') and immediately distinguishes itself from the type_text sibling by explaining that it fires trusted key events rather than bulk text insertion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear selection rule: use this when a framework listens for key events that type_text's bulk insert does not fire. The alternative is named with the condition that selects it, though no explicit 'do not use for typing text' exclusion is stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.