ReferenceInput

keypress

Queues a key-down event for the game. Pair it with keyrelease when the key should stop being held.

Syntax

keypress(key: number | string) -> ()

Also available as

key_press

Parameters

ParameterTypeDescription
keynumber or stringSupported virtual-key code or key name.

Description

A key can be a supported Windows virtual-key number from 0 through 255 or a recognized name such as Space, Enter, LeftShift or F1 through F24. These events enter the current game instance; they do not type into arbitrary desktop applications. Unsupported keys and an unavailable or full input queue raise errors.

Example

keypress("Space")
task.wait(0.1)
keyrelease("Space")

These are Game executor contracts. Check build requirements and session lifetimes before using them.