unbindKey
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.
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
unbindKey ( )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