bindKey
Client-side
Server-side
Shared
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
Binds a player's key to a handler function or command, which will be called when the key is pressed.
Note
Using escape key or F8 key will always return false. Use onClientKey event instead.
Note
Handler function won't be triggered while focused in CEGUI editbox. You can use guiSetInputMode or onClientKey in order to fix that.
Syntax
bindKey ( )Code Examples
server
This example will bind a player's 'F1' key and 'fire' control to 1 input function.
function funcInput ( player, key, keyState ) outputChatBox ( getPlayerName ( player) .. " " .. (keyState == "down" and "pressed" or "released") .. " the " .. key .. " key!" )end
function bindTheKeys ( player, commandName ) bindKey ( player, "F1", "down", funcInput ) -- bind the player's F1 down key bindKey ( player, "F1", "up", funcInput ) -- bind the player's F1 up key bindKey ( player, "fire", "both", funcInput ) -- bind the player's fire down and up controlendaddCommandHandler ( "bindme", bindTheKeys )See Also
Input Functions
- addCommandHandler
- bindKey
- executeCommandHandler
- getAnalogControlState
- getBoundKeys
- getCommandHandlers
- getCommandsBoundToKey
- getFunctionsBoundToKey
- getKeyBoundToCommand
- getKeyBoundToFunction
- getKeyState
- isCapsLockEnabled
- isControlEnabled
- isKeyBound
- removeCommandHandler
- setAnalogControlState
- toggleAllControls
- toggleControl
- unbindKey
Input Events
- onClientCharacter
- onClientClick
- onClientCursorMove
- onClientDoubleClick
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientKey
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
- onClientPaste