onClientKey
ClientEventCancellable
Fired when a key or mouse button is pressed or released. Cancelling the event stops that key's binds and, on a press, hides the key from the game while it is held.
addEventHandler("onClientKey", root, function(string button, bool pressOrRelease) … end)
Handler parameters
| Name | Type | Description |
|---|---|---|
| button | string | The key's name, as bindKey uses it. |
| pressOrRelease | bool | true on press, false on release. |
Source
The root element (root).
When it is cancelled, the server is not told about the key either, so server binds do not fire. The mouse wheel arrives as mouse_wheel_up or mouse_wheel_down, pressed and released right away.
Example
addEventHandler("onClientKey", root, function(button, pressed)
if button == "f" and pressed and isCursorShowing() then
cancelEvent()
end
end)