inject_input
Dispatch keyboard, mouse, or touch events to a running PlayCanvas Launch instance to drive end-to-end interactions like pressing keys, clicking buttons, or tapping the screen.
Instructions
Dispatch keyboard / mouse / touch input to the RUNNING Launch instance so you can drive end-to-end interactions ("press W to move", "click a button", "tap the screen"). Requires launch_start first. Events run in order; coordinates are CSS pixels from the canvas top-left (match capture_runtime's framing). Returns { dispatched }. Mouse and touch events are dispatched as PointerEvents plus the matching MouseEvent/TouchEvent, so both the engine's pointer-based input sources (camera-controls, first-person-controller) and legacy pc.Mouse / pc.TouchDevice receive them. Patterns: key press with holdMs to move for a duration; mouse click at (x,y); a down→move…→up sequence for dragging; touch tap for mobile UI. After injecting, use capture_runtime / read_runtime_logs / query the scene to observe the effect. When NOT to use: to change entity data directly (use modify_entities) or before launch_start.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| events | Yes | Ordered list of input events to dispatch | |
| betweenMs | No | Delay between consecutive events (default 0) |