Simulate a keyboard key press
press-keySimulates a real keyboard press and release in a running Roblox client via VirtualInputManager to trigger input events, movement, or keybound abilities, with optional hold duration.
Instructions
WRITES LIVE GAME STATE. Simulate a real keyboard key press/release in the running client via VirtualInputManager, so anything listening for keyboard input runs: UserInputService.InputBegan/InputEnded, ContextActionService bindings, default movement, and keybound abilities. The key string is resolved against Enum.KeyCode (e.g. 'E', 'Space', 'W', 'LeftShift', 'F'); an unknown name returns a clean error listing what you passed. Sends KeyDown immediately, optionally holds for holdSec seconds (via task.wait) to emulate a held key, then sends KeyUp. NOTE: VirtualInputManager:SendKeyEvent only works from an exploit/elevated context (injected executor thread) — in an ordinary game script it is locked and will error. Getting the service and each SendKeyEvent are pcall-guarded. WARNING: this drives real input into the game and may move the character or trigger abilities. Returns { key, ok, error? }. Signature: { key: string, holdSec: any?, threadContext: number? }. Phase: act; cost=medium; idempotency=contextual-write. Requires: active-client, explicit-mutation-approval. Capabilities: VirtualInputManager. Produces: structured-result. Verify with: assert-state. Safety: MUTATING; writes live game/client state. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The Enum.KeyCode name to press, e.g. 'E', 'Space', 'W', 'A', 'S', 'D', 'LeftShift', 'F', 'Return', 'One'. Case-sensitive and must match an Enum.KeyCode member exactly. Resolved as Enum.KeyCode[key]. | |
| holdSec | No | How long (seconds) to hold the key down before releasing it. Default 0 = a quick tap (KeyDown then immediate KeyUp). Use a small positive value (e.g. 0.5) to emulate a held key for charge/hold mechanics. Capped at 10 seconds to avoid blocking the executor thread. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |