Skip to Content
defold-typescript libraries
britzldefold-input

britzl/defold-input/in.state

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 state from "in.state"

Functions

create(): StateInstanceU

Create an instance of the input state tracker

Returns

  • StateInstance — State instance

acquire(url: Url, instance?: StateInstance)U

Acquire input focus for the current script and clear state

Parameters

  • url: Url
  • instance?: StateInstance — Optional state instance to modify. Will use global state instance if none is specified

release(url: Url, instance?: StateInstance)U

Release input focus for the current script and clear state

Parameters

  • url: Url
  • instance?: StateInstance — Optional state instance to modify. Will use global state instance if none is specified

is_pressed(action_id: Hash | string, instance?: StateInstance): booleanU

Check if an action is pressed/active

Parameters

  • action_id: Hash | string
  • instance?: StateInstance — Optional state instance to modify. Will use global state instance if none is specified

Returns

  • boolean — true if pressed/active

update(action_id: Hash | string, action: {}, instance?: StateInstance)U

Forward any calls to on_input from scripts using this module

Parameters

  • action_id: Hash | string
  • action: {}
  • instance?: StateInstance — Optional state instance to modify. Will use global state instance if none is specified

on_input(action_id: Hash | string, action: {}, instance?: StateInstance)

Parameters

  • action_id: Hash | string
  • action: {}
  • instance?: StateInstance

clear(instance?: StateInstance)U

Clear the state of any currently tracked input states

Parameters

  • instance?: StateInstance — Optional state instance to modify. Will use global state instance if none is specified

Types

StateInstance

StateInstance.acquire: () => void

StateInstance.release: (url?: Url) => void

StateInstance.is_pressed: (action_id: Hash | string) => boolean

StateInstance.on_input: (action_id: Hash | string, action: {}) => void

StateInstance.clear: () => void

On this page