OnClientKey

From Multi Theft Auto: Wiki
Revision as of 20:33, 29 March 2011 by Arran Fortuna (talk | contribs) (Created page with "{{Client event}} __NOTOC__ This event triggers whenever the user presses a button on their keyboard. ==Parameters== <syntaxhighlight lang="lua">string button, bool pressOrRelease </syntaxhighlight> * ''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This event triggers whenever the user presses a button on their keyboard.

Parameters

string button, bool pressOrRelease
  • button: This refers the button pressed.
  • pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing.

Source

The source of this event is the client's root element.

Example

This example will say in chatbox every time the user presses down a a key.

function playerPressedKey(button, press)
    if (press) then -- Only output when they press it down
        outputChatBox("You pressed the "..button.." key!")
    end
end
addEventHandler("onClientKey", root, playerPressedKey)

See Also

GUI events

Input

GUI


Client event functions