Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.50

Description

Description:Assigns a command to a key or joystick input (identical to bindKey, but allows suppression of default actions using the standard syntax as well).

If the command returns false (or nothing at all), then both, the original action, as well as the newly defined action, are executed at the same time.

If the command returns true (by making it the last command in the script string), then the original behavior associated with the action (or keystroke) is suppressed, and only the newly defined command is executed.

Syntax

Syntax:key bindKeyEx command
Parameters:
Return Value:Number - Key index (to use with unBindKey).

Alternative Syntax

Syntax:[key, float, rule] bindKeyEx command (V1.30+)
Parameters:
  • key: String or Number - Name of a VBS Key Actions or a DIK KeyCodes.
  • float: Boolean - Whether to get the float inputs from a joystick (true) or a Boolean from a key (false).
  • rule: Number - When the newly defined command should be executed:
    • 0 (with float true): Constantly, while the button is pressed.
    • 0 (with float false): Once, when the button is pressed.
    • 1: Once per value change (either joystick move, or once per button press and release).
    • 2: Constantly (once per simulation step). If used with keyboard input, _value returns 1, while button is pressed, otherwise 0 is returned. For joystick input, the current float value is returned.
  • command: String or Code - Script code to run (see description for details).
Return Value:Number - Key index (to use with unBindKey).

Examples

Examples:
Disarms the player, as they step forward:
"MoveForward" bindKeyEx "removeAllWeapons player"
Disarm the player, as they press the up-arrow key:
0xC8 bindKeyEx "removeAllWeapons player"
Suppresses the inventory command, and display a message instead:
["Gear",false,0] bindKeyEx "hint 'no inventory'; true"

Additional Information

See also: bindKey, actionKeysNames, unBindKey, isKeyPressed, inputAction, ctrlSetEventHandler, displaySetEventHandler
Multiplayer: 
Problems: 

Notes