inject_key_input
Press or release keyboard/gamepad keys in a running PIE session so an agent can drive headless gameplay or move UI focus.
Instructions
Press or release a keyboard/gamepad key at a running PIE session's PlayerController, so an agent can drive the game headless -- jump, interact, open a menu. Press and release are SEPARATE calls: a tap is two of them, a hold is press now and release later. Requires an active PIE session; use inject_analog_input for sticks and triggers (with its hold_seconds for sustained movement) and inject_mouse_button for clicks. WARNING: injected only means the event reached the controller: whether the game DID anything is a state read, and in co-op read the right world.
Returns: { injected: bool, key: string, event: string, pie_client_index: int, route: string, controller_injected: bool, slate_injected: bool, slate_handled: bool, slate_note? } -- NOTE: slate_handled is Slate's own verdict on whether anything consumed the key: false usually means nothing had focus, which is the useful signal (not a failure of the call).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Required key name as Unreal spells it, e.g. "SpaceBar", "W", "Gamepad_FaceButton_Bottom". An unknown name is a clean error, never a silent no-op. | |
| event | No | Optional "Pressed" (default), "Released" or "Repeat". Remember the matching Released, or the game keeps thinking the key is down. | |
| route | No | Optional "controller" (default), "slate" or "both". NOTE: THIS IS THE DIFFERENCE BETWEEN DRIVING THE GAME AND DRIVING THE UI: the controller route goes through PlayerController::InputKey, which is the gameplay input layer -- it moves the character and fires Enhanced Input actions but NEVER moves UI focus. The slate route goes through FSlateApplication::ProcessKeyDownEvent, which is the only one that moves FOCUS, so it is the only way to test a menu's gamepad navigation headless. They are not interchangeable; "both" sends to each. | |
| amount_depressed | No | Optional float (default 1.0). Only meaningful on the controller route. | |
| pie_client_index | No | Optional int (default 0). Which PIE client window to target -- 0 is the server/host window in a ListenServer session, 1 the first client. |