util.input.is_pressed
Client
Checks whether a keyboard or mouse button is currently held down
Syntax
local result = util.input.is_pressed(
key
)Parameters
| Type | Name | Description |
|---|---|---|
util.input.key | key | Key or button to query |
Returns
| Type | Name | Description |
|---|---|---|
bool | result | true if the key or button is currently held down, false otherwise |
Examples
if util.input.is_pressed(util.input.key.W) then
core.engine.print("info", "W is held")
endif util.input.is_pressed(util.input.key.MOUSE_LEFT) then
core.engine.print("info", "Left mouse button is held")
endlocal moving = util.input.is_pressed(util.input.key.W)
local sprinting = moving and util.input.is_pressed(util.input.key.SHIFT)
core.engine.print("info", "Sprinting:", sprinting)