unbindKey
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
Removes an existing key bind from the specified player.
Note
unbindKey will only work on binds that were added by the same resource
Note
unbindKey on the server may return true on failure
Note
If you call unbindKey twice, it will break other scripts: Issue 497
Syntax
bool unbindKey ( string key, string keyState, string command )Required Arguments
- key: The key you wish to unbind. See Key names for a list of valid key names.
- keyState: is optional in Syntax 2.
- command: MISSING_PARAM_DESC
Returns
- bool: value
Returns ' true if the key was unbound, false if it was not previously bound or invalid arguments were passed to the function.
Code Examples
server
This function binds the player'sF1key to a functiongoMoowhich outputs a chat message when pressed. The key is then unbound so that it can effectively only be used once per life.
-- define the function that will be called when F1 is pressedfunction goMoo( player ) outputChatBox ( getPlayerName ( player ) .. " says Mooooooo!" ) unbindKey ( player, "F1", "down", goMoo ) -- this function will no longer be triggered by the player, after removing the bind.end
function playerSpawn ( ) bindKey ( source, "F1", "down", goMoo ) -- bind the player's F1 key to the 'goMoo' function defined aboveendaddEventHandler ( "onPlayerSpawn", root, playerSpawn ) -- make the playerSpawn function be called when a player spawnsSee 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