Scripting/Client/Functions/BindKey
Calls callback when the key goes down (BINDTYPE_DOWN) or up (BINDTYPE_UP). key is a KEY_* constant, a virtual-key integer, a one-character string ("H", "7") or a name ("SPACE", "F5", "CTRL"...). callback is a function name (string) or a function value; up to 4 extra arguments are passed to it. Several different handlers can share a key. Binds do not fire while the chat box is open.
Syntax
BindKey(key, type, callback [, arg1 .. arg4])Arguments
- string key –
keyis aKEY_*constant, a virtual-key integer, a one-character string ("H","7") or a name ("SPACE","F5","CTRL"...). - int type
- string callback – Calls
callbackwhen the key goes down (BINDTYPE_DOWN) or up (BINDTYPE_UP). - any arg1 .. arg4 (optional)
Returns
bool (false on a bad key/arguments)
Example
function onScriptLoad()
{
local result = BindKey( "X", 0, "myFunction" );
MessagePlayer( "BindKey returned: " + result, player );
}This sample was generated from the signature – adapt the values to your gamemode.
Related pages
- UnbindKey
- GetKeyStatus
- ShowMouseCursor
- GetMouseCursorPos
- SetMouseCursorPos
- SetDriveBy
- ToggleCameraMovement
- ToggleMouseMovement
- ToggleWaterShader
- ToggleDynamicShadows
- ToggleBulletHoles
- SetCameraFov
Section: Input
Categories: Client functions | Input