keydown
Alias of iskeypressed.
Syntax
keydown(key: number | string | Enum.KeyCode) -> boolean
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | string | Enum.KeyCode | Virtual-key code, key name or Enum.KeyCode item. |
Returns
| Type | Description |
|---|---|
boolean | True while the key is held and the game is focused. |
Description
The function accepts the same formats as iskeypressed, including letters, digits, function keys and names such as "space", "shift", "ctrl" and "escape".
Example
if keydown("e") then
print("E held")
end
Notes
- It reports false when the Roblox window is not focused.
- Use
keyupstyle logic by tracking the previous state in your script.