Skip to main content

Trigger

Description:

  Trigger is a record that defines various input triggers for keyboard keys, gamepad buttons, and joysticks.

KeyDown

Type: Function.

Description:

  Create a trigger that triggers when all of the specified keys are pressed down.

Signature:

KeyDown: function(combineKeys: KeyName | {KeyName}): Trigger

Parameters:

ParameterTypeDescription
combineKeysKeyName{KeyName}

Returns:

Return TypeDescription
TriggerThe trigger object.

KeyUp

Type: Function.

Description:

  Create a trigger that triggers when all of the specified keys are pressed down and then any of them is released.

Signature:

KeyUp: function(combineKeys: KeyName | {KeyName}): Trigger

Parameters:

ParameterTypeDescription
combineKeysKeyName{KeyName}

Returns:

Return TypeDescription
TriggerThe trigger object.

KeyPressed

Type: Function.

Description:

  Create a trigger that triggers when all of the specified keys are being pressed.

Signature:

KeyPressed: function(combineKeys: KeyName | {KeyName}): Trigger

Parameters:

ParameterTypeDescription
combineKeysKeyName{KeyName}

Returns:

Return TypeDescription
TriggerThe trigger object.

KeyHold

Type: Function.

Description:

  Create a trigger that triggers when a specific key is held down for a specified duration.

Signature:

KeyHold: function(keyName: KeyName, holdTime: number): Trigger

Parameters:

ParameterTypeDescription
keyNameKeyNameThe key to be checked.
holdTimenumberThe duration in seconds.

Returns:

Return TypeDescription
TriggerThe trigger object.

KeyTimed

Type: Function.

Description:

  Create a trigger that triggers when a specific key is pressed within a specified time window.

Signature:

KeyTimed: function(keyName: KeyName, timeWindow: number): Trigger

Parameters:

ParameterTypeDescription
keyNameKeyNameThe key to be checked.
timeWindownumberThe time window in seconds.

Returns:

Return TypeDescription
TriggerThe trigger object.

KeyDoubleDown

Type: Function.

Description:

  Create a trigger that triggers when a specific key is double-pressed within a specified time window.

Signature:

KeyDoubleDown: function(key: KeyName, threshold?: number): Trigger

Parameters:

ParameterTypeDescription
keyKeyNameThe key to be checked.
thresholdnumber[optional] The time window in seconds. Default is 0.3.

Returns:

Return TypeDescription
TriggerThe trigger object.

AnyKeyPressed

Type: Function.

Description:

  Create a trigger that triggers when any key is being pressed down.

Signature:

AnyKeyPressed: function(): Trigger

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonDown

Type: Function.

Description:

  Create a trigger that triggers when all of the specified gamepad buttons are pressed down.

Signature:

ButtonDown: function(combineButtons: ButtonName | {ButtonName}, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
combineButtonsButtonName{ButtonName}
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonUp

Type: Function.

Description:

  Create a trigger that triggers when all of the specified gamepad buttons are pressed down and then any of them is released.

Signature:

ButtonUp: function(combineButtons: ButtonName | {ButtonName}, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
combineButtonsButtonName{ButtonName}
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonPressed

Type: Function.

Description:

  Create a trigger that triggers when all of the specified gamepad buttons are being pressed.

Signature:

ButtonPressed: function(combineButtons: ButtonName | {ButtonName}, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
combineButtonsButtonName{ButtonName}
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonHold

Type: Function.

Description:

  Create a trigger that triggers when a specific gamepad button is held down for a specified duration.

Signature:

ButtonHold: function(buttonName: ButtonName, holdTime: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
buttonNameButtonNameThe gamepad button to be checked.
holdTimenumberThe duration in seconds.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonTimed

Type: Function.

Description:

  Create a trigger that triggers when a specific gamepad button is pressed within a specified time window.

Signature:

ButtonTimed: function(buttonName: ButtonName, timeWindow: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
buttonNameButtonNameThe gamepad button to be checked.
timeWindownumberThe time window in seconds.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

ButtonDoubleDown

Type: Function.

Description:

  Create a trigger that triggers when a specific gamepad button is double-pressed within a specified time window.

Signature:

ButtonDoubleDown: function(button: ButtonName, threshold?: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
buttonButtonNameThe gamepad button to be checked.
thresholdnumber[optional] The time window in seconds. Default is 0.3.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

AnyButtonPressed

Type: Function.

Description:

  Create a trigger that triggers when any gamepad button is being pressed down.

Signature:

AnyButtonPressed: function(controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

JoyStick

Type: Function.

Description:

  Create a trigger that triggers based on joystick movement.

Signature:

JoyStick: function(joyStickType: JoyStickType, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
joyStickTypeJoyStickTypeThe type of joystick to be checked.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

JoyStickThreshold

Type: Function.

Description:

  Create a trigger that triggers when a joystick moves beyond a specified threshold.

Signature:

JoyStickThreshold: function(joyStickType: JoyStickType, threshold: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
joyStickTypeJoyStickTypeThe type of joystick to be checked.
thresholdnumberThe threshold value, ranging from 0 to 1.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

JoyStickDirectional

Type: Function.

Description:

  Create a trigger that triggers when a joystick is moved in a specific direction within a tolerance angle.

Signature:

JoyStickDirectional: function(joyStickType: JoyStickType, angle: number, tolerance: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
joyStickTypeJoyStickTypeThe type of joystick to be checked.
anglenumberThe angle of the direction in degrees.
tolerancenumberThe tolerance angle in degrees.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

JoyStickRange

Type: Function.

Description:

  Create a trigger that triggers when a joystick is within a specified range.

Signature:

JoyStickRange: function(joyStickType: JoyStickType, minRange: number, maxRange: number, controllerId?: number): Trigger

Parameters:

ParameterTypeDescription
joyStickTypeJoyStickTypeThe type of joystick to be checked.
minRangenumberThe minimum range value, ranging from 0 to 1.
maxRangenumberThe maximum range value, ranging from 0 to 1.
controllerIdnumber[optional] The ID of the gamepad controller. Default is 0.

Returns:

Return TypeDescription
TriggerThe trigger object.

Sequence

Type: Function.

Description:

  Create a trigger that triggers when a sequence of other triggers are completed at the same time.

Signature:

Sequence: function(triggers: {Trigger}): Trigger

Parameters:

ParameterTypeDescription
triggers{Trigger}The triggers to be checked.

Returns:

Return TypeDescription
TriggerThe trigger object.

Selector

Type: Function.

Description:

  Create a trigger that triggers when any of the specified triggers is completed.

Signature:

Selector: function(triggers: {Trigger}): Trigger

Parameters:

ParameterTypeDescription
triggers{Trigger}The triggers to be checked.

Returns:

Return TypeDescription
TriggerThe trigger object.

Block

Type: Function.

Description:

  Create a trigger when a sub-trigger is in completed state, it will report canceled state instead for blocking.

Signature:

Block: function(trigger: Trigger): Trigger

Parameters:

ParameterTypeDescription
triggerTriggerThe trigger to be blocked.

Returns:

Return TypeDescription
TriggerThe trigger object.