Roblox UtilitiesDevlHub Roblox Documentation

Class

InputBinding

Inherits
Instance › Object
Memory category
Instances

Defines which hardware binding should trigger the parent InputAction.

An InputBinding defines which hardware binding should trigger the parent InputAction, for example a key press, gamepad button, or tap on a touch‑enabled device. There can be multiple InputBinding instances parented to an InputAction.

Properties 22#

BackwardKeyCodeSpecifies an alternate KeyCode for dispatching directionally "backward" inputs to the parent InputAction.ReadSafe
ClampMagnitudeToOnebooleanSpecifies how the binding normalizes composite directional input to a maximum magnitude of 1.ReadSafe
DisplayImageContentCustom image asset to display for this binding.ReadSafe
DisplayNamestringCustom display text for this binding.ReadSafe
DownKeyCodeSpecifies an alternate KeyCode for dispatching directionally "down" inputs to the parent InputAction.ReadSafe
ForwardKeyCodeSpecifies an alternate KeyCode for dispatching directionally "forward" inputs to the parent InputAction.ReadSafe
KeyCodeKeyCodeSpecifies the KeyCode which triggers the parent InputAction.ReadSafe
LeftKeyCodeSpecifies an alternate KeyCode for dispatching directionally "left" inputs to the parent InputAction.ReadSafe
PointerIndexintReadSafe
PressedThresholdfloatNumerical value above which to fire an InputAction with a Type of Bool.ReadSafe
PrimaryModifierKeyCodeSpecifies a primary KeyCode that must be pressed for the binding to activate.ReadSafe
ReleasedThresholdfloatNumerical value below which to fire an InputAction with a Type of Bool.ReadSafe
ResponseCurvefloatNumerical value to configure scaling for more precise thumbstick aiming.ReadSafe
RightKeyCodeSpecifies an alternate KeyCode for dispatching directionally "right" inputs to the parent InputAction.ReadSafe
ScalefloatScalar multiplier applied uniformly to all components of a directional InputAction's output.ReadSafe
SecondaryModifierKeyCodeSpecifies a secondary KeyCode that must be pressed for the binding to activate.ReadSafe
TypeInputBindingTypeDetermines whether this binding is triggered by hardware input or programmatically via Fire().ReadSafe
UIButtonGuiButtonConnects a GuiButton to a boolean action.ReadSafe
UIModifierGuiButtonSpecifies a GuiButton that must be active for the binding to activate.ReadSafe
UpKeyCodeSpecifies an alternate KeyCode for dispatching directionally "up" inputs to the parent InputAction.ReadSafe
Vector2ScaleVector2Per-component scale applied to the output of a Direction2D action.ReadSafe
Vector3ScaleVector3Per-component scale applied to the output of a Direction3D action.ReadSafe

Backward: KeyCode#

ReadSafe

Specifies an alternate KeyCode for dispatching directionally "backward" inputs to GetState() and the StateChanged event of the parent InputAction. Only applies when the parent action's Type is Direction3D, in which case the dispatched value will be a Vector3 with its Z component between 0 and 1.

ClampMagnitudeToOne: boolean#

ReadSafe

Determines whether the binding normalizes the combined composite directional vector to a maximum magnitude of 1 only if it exceeds that length. This prevents diagonal composite inputs (for example Up and Right pressed simultaneously) from producing a magnitude greater than 1, ensuring consistent movement speed regardless of the keys held. Default is true.

This property only applies when the parent action's Type is Direction1D, Direction2D, or Direction3D.

Set this to false when input axes should remain independent of one another, such as 3D freecam movement, or when combining inputs whose raw values can exceed 1 (for example mouse wheel velocity) and you want to handle scaling yourself.

DisplayImage: Content#

ReadSafe

A custom Content image asset that represents this binding visually (for example a gamepad button image or a stylized key graphic).

When empty (the default), no custom image is provided. Developers can use UserInputService:GetImageForKeyCode() to obtain a platform-appropriate image. Use this together with InputAction.PreferredBinding to build keybinding UI that automatically reflects the player's active input device without manually resolving which binding image to display.

DisplayName: string#

ReadSafe

A custom string that overrides the display name shown for this binding in UI elements such as key prompts (for example "FIGHT" instead of the default key name "F").

When empty (the default), no custom name is provided. Developers can use UserInputService:GetStringForKeyCode() to obtain the platform-appropriate key name. Use this together with InputAction.PreferredBinding to build keybinding UI that automatically reflects the player's active input device without manually resolving which binding name to display.

Down: KeyCode#

ReadSafe

Specifies an alternate KeyCode for dispatching directionally "down" inputs to GetState() and the StateChanged event of the parent InputAction.

When the parent action's Type is Direction1D, the dispatched value will be a number between 0 and -1.

When the parent action's Type is Direction2D, the dispatched value will be a Vector2 with its Y component between 0 and -1.

When the parent action's Type is Direction3D, the dispatched value will be a Vector3 with its Y component between 0 and -1.

Not applicable when the parent action's Type is Bool.

Forward: KeyCode#

ReadSafe

Specifies an alternate KeyCode for dispatching directionally "forward" inputs to GetState() and the StateChanged event of the parent InputAction. Only applies when the parent action's Type is Direction3D, in which case the dispatched value will be a Vector3 with its Z component between 0 and -1.

KeyCode: KeyCode#

ReadSafe

Specifies the KeyCode which triggers the parent InputAction. The code type should match the input action's Type, for example KeyCode.E for an action type of Bool or KeyCode.Thumbstick1 for an action type of Direction2D. Type mismatches will either not fire the InputAction or the StateChanged event will receive a converted value.

Left: KeyCode#

ReadSafe

Specifies an alternate KeyCode for dispatching directionally "left" inputs to GetState() and the StateChanged event of the parent InputAction.

When the parent action's Type is Direction2D, the dispatched value will be a Vector2 with its X component between 0 and -1.

When the parent action's Type is Direction3D, the dispatched value will be a Vector3 with its X component between 0 and -1.

Not applicable when the parent action's Type is Direction1D or Bool.

PointerIndex: int#

ReadSafe

PressedThreshold: float#

ReadSafe

Numerical value above which to fire an InputAction with a Type of Bool, for example when a gamepad trigger such as KeyCode.ButtonL2 exceeds 0.5 (halfway pressed). Default is 0.5.

This property must be greater than or equal to ReleasedThreshold or else it will be clamped to ReleasedThreshold.

PrimaryModifier: KeyCode#

ReadSafe

Specifies a KeyCode that serves as a required modifier for the binding. The InputBinding will only trigger the parent InputAction if this input is pressed prior to KeyCode, UIButton, or composite directions.

There is no ordering requirement between PrimaryModifier and SecondaryModifier. If both properties are set, both modifiers must be pressed to activate the binding, but the order in which they are pressed does not matter.

If set to KeyCode.Unknown, no primary modifier is required.

ReleasedThreshold: float#

ReadSafe

Numerical value below which to fire an InputAction with a Type of Bool, for example when a gamepad trigger such as KeyCode.ButtonL2 falls below 0.5 (less than halfway pressed). Default is 0.2.

This property must be less than or equal to PressedThreshold or else it will be clamped to PressedThreshold.

ResponseCurve: float#

ReadSafe

A numerical value to control the sensitivity of gamepad thumbstick input by applying a quadratic response curve. Commonly used for camera control to make small thumbstick inputs more precise, while ramping up quickly to allow for large movements with higher magnitude input.

Ranges between 1 to 10, with higher values providing a more intense curve. Default is 1, at which input is returned exactly as received.

Only applicable when the parent action's Type is Direction2D and the KeyCode is Thumbstick1 or Thumbstick2.

Scale: float#

ReadSafe

A scalar multiplier applied uniformly to every component of the output value. Applies to InputAction types Direction1D, Direction2D, and Direction3D.

To scale individual components independently, use Vector2Scale (for Direction2D) or Vector3Scale (for Direction3D). When both Scale and a vector scale are set, both are applied.

SecondaryModifier: KeyCode#

ReadSafe

Specifies a KeyCode that serves as a required modifier for the binding. The InputBinding will only trigger the parent InputAction if this input is pressed prior to KeyCode, UIButton, or composite directions.

There is no ordering requirement between PrimaryModifier and SecondaryModifier. If both properties are set, both modifiers must be pressed to activate the binding, but the order in which they are pressed does not matter.

If set to KeyCode.Unknown, no secondary modifier is required.

Type: InputBindingType#

ReadSafe

Determines whether this InputBinding is triggered by hardware input (Automatic) or programmatically via Fire() (Scriptable).

When set to Automatic (default), the binding responds to physical input devices (keyboard, mouse, gamepad, touch) based on its KeyCode or composite direction or UI button properties.

When set to Scriptable, the binding ignores hardware input and instead receives state updates exclusively through the Fire() method.

UIButton: GuiButton#

ReadSafe

GuiButton to connect to a boolean action.

UIModifier: GuiButton#

ReadSafe

Specifies a GuiButton that must be pressed for the InputBinding to trigger the parent InputAction. Behaves similarly to PrimaryModifier and SecondaryModifier, but accepts a UI button reference rather than a KeyCode.

This is particularly useful for touch input where the relevant interaction is defined by where on screen the touch originates, for example a dynamic thumbstick that should only respond to touches that begin within a specific UI region.

If nil, no modifier is required.

Up: KeyCode#

ReadSafe

Specifies an alternate KeyCode for dispatching directionally "up" inputs to GetState() and the StateChanged event of the parent InputAction.

When the parent action's Type is Direction1D, the dispatched value will be a number between 0 and 1.

When the parent action's Type is Direction2D, the dispatched value will be a Vector2 with its Y component between 0 and 1.

When the parent action's Type is Direction3D, the dispatched value will be a Vector3 with its Y component between 0 and 1.

Not applicable when the parent action's Type is Bool.

Vector2Scale: Vector2#

ReadSafe

Amount by which each component of the output is independently linearly scaled. Only applies when the parent action's Type is Direction2D.

Vector3Scale: Vector3#

ReadSafe

Amount by which each component of the output is independently linearly scaled. Only applies when the parent action's Type is Direction3D.

Methods 1#

FireProgrammatically updates the parent InputAction state through this binding.

Fire(state: Variant): ()#

Programmatically updates the parent InputAction to the given state and fires the appropriate signals (Pressed, Released, StateChanged).

This method can only be called on bindings with Type set to Scriptable. Calling it on an Automatic binding will throw an error.

The state parameter must match the Type of the parent InputAction:

Passing a mismatched type will cause an error. This method respects the same deduplication rules as hardware input, as in consecutive calls with the same state value will not re‑fire events.

The parent InputAction must be Enabled and its ancestor InputContext must also be Enabled, otherwise the call is silently ignored.

NameTypeDefaultDescription
stateVariantThe state value to apply; must match the parent action's Type.
Returns
  • ()

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed