Skip to Content
defold-typescript libraries
britzldefold-input

britzl/defold-input/in.mapper

Cross-platform input handling for Defold: keyboard, mouse, gamepad, touch, and on-screen controls.

  • GitHub: britzl/defold-input — pinned to 4.9.0
    1. Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as mapper from "in.mapper"

Functions

bind(trigger: {}, action: {}, player?: any, gamepad?: any): unknownU

Bind an input trigger to an action, optionally associating the binding to a specific player

Parameters

  • trigger: {} — The input trigger to bind (key, gamepad, mouse etc)
  • action: {} — The action that will be generated by the trigger
  • player?: any — Optional id for a player to bind input trigger to
  • gamepad?: any — Gamepad index to bind the trigger to. 0️⃣ 0-based; passed to in.mapper unchanged.

Returns

  • unknown — Any previous action bound to the trigger

unbind(trigger: {}, player?: any)U

Unbind (remove) an existing input binding

Parameters

  • trigger: {} — The input trigger to unbind (key, gamepad, mouse etc)
  • player?: any — Optional id for a player to unbind input trigger from

unbind_all(player?: any)U

Unbind (remove) all input trigger bindings

Parameters

  • player?: any — Optional id for a player to unbind input triggers from

on_input(trigger: {}, player?: any, gamepad?: any): {} | undefinedU

Handle incoming input trigger from a script by finding an binding and returning the bound action

Parameters

  • trigger: {} — The input trigger received from on_input funcion (ie action_id)
  • player?: any — Optional id for a player to get input trigger binding for
  • gamepad?: any — Gamepad index the trigger came from, action.gamepad. 0️⃣ 0-based; passed to in.mapper unchanged.

Returns

  • {} | undefined — The bound action or nil if no binding exists

On this page