M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
buttonstringThe key's name, as bindKey uses it.
pressOrReleasebooltrue 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)

See also