- Documentation
- Client functions
- getKeyState
Function
getKeyState
Checks whether a key is held down right now. Works without bindKey too, e.g. in onClientRender.
Syntax
bool getKeyState(string key)Arguments
keystring- The key, e.g.
"lshift","w","mouse2".
Returns
true when the key is down.
Example
addEventHandler("onClientRender", root, function()
if getKeyState("lalt") then
dxDrawText("Trzymasz Alt", 20, 300)
end
end)
See also
bindKeyBinds a function or a command to a player's key. The function gets (on the server also the player) the key name, the state and the extra arguments frombindKey. Instead of a function you can pass a command name: the key runs it like/command. On the server the player's game watches the key and reports presses to the server.getControlStateReturns the control state set withsetControlState.