onClientKey
Client-side
Server-side
Shared
This event triggers whenever the user presses a button on their keyboard or mouse. This event can also be used to see if the client scrolls their mouse wheel.
F8 key not triggered on this event!
Parameters
string button, bool pressOrRelease
- button: This refers the button pressed. See key names for a list of keys.
- pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing.
Source
element: The source of this event is the client's root element.
Canceling
If this event is canceled, then all GTA and MTA binds, bound to the canceled key, won't be triggered.
Code Examples
client
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!") endendaddEventHandler("onClientKey", root, playerPressedKey)
See Also
Input Events
- onClientCharacter
- onClientClick
- onClientCursorMove
- onClientDoubleClick
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIFocus
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientKey
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
- onClientPaste
Input Functions
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey
- getAnalogControlState
- getCommandsBoundToKey
- getBoundKeys
- getKeyBoundToCommand
- getKeyState
- isCapsLockEnabled
- setAnalogControlState
- isKeyBound