bindKey | Multi Theft Auto: Wiki Skip to content

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 control
end
addCommandHandler ( "bindme", bindTheKeys )