Skip to Content
defold-typescript libraries
britzldefold-input

britzl/defold-input/in.button

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

Functions

acquire()U

Convenience function to acquire input focus

release()U

Convenience function to release input focus

register(node_or_string: Opaque<"node"> | string, callback: () => void): Opaque<"node">U

Register a node and a callback to invoke when it is clicked

Parameters

  • node_or_string: Opaque<"node"> | string
  • callback: () => void

Returns

  • Opaque<"node">

unregister(node_or_string?: Opaque<"node"> | string)U

Unregister a previously registered node or all nodes registered from the calling script

Parameters

  • node_or_string?: Opaque<"node"> | string

dump()

effect(node: Opaque<"node">, initial_scale: Vector3)

Parameters

  • node: Opaque<"node">
  • initial_scale: Vector3

on_input(action_id: Hash, action: {}): booleanU

Forward on_input calls to this function to detect input for registered nodes

Parameters

  • action_id: Hash
  • action: {}

Returns

  • boolean — true if input a registerd node received input

Variables

TOUCH: Hash

On this page