Skip to Content
defold-typescript libraries
britzldefold-input

britzl/defold-input/in.gesture

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

Functions

create(settings?: { action_id?: string; tap_threshold?: number; double_tap_interval?: number; swipe_threshold?: number; swipe_time?: number; long_press_time?: number; multi_touch?: boolean; }): GestureInstanceU

Create a gesture instance. Use this if you need multiple gesture detectors that each needs unique settings

Parameters

  • settings?: { action_id?: string; tap_threshold?: number; double_tap_interval?: number; swipe_threshold?: number; swipe_time?: number; long_press_time?: number; multi_touch?: boolean; }
    • action_id?: string
    • tap_threshold?: number
    • double_tap_interval?: number
    • swipe_threshold?: number
    • swipe_time?: number
    • long_press_time?: number
    • multi_touch?: boolean

Returns

  • GestureInstance — Gesture instance

on_input(this: any, action_id: Hash, action: {}): DetectedGesturesU

Forward calls to on_input to this function to detect supported gestures

Parameters

  • this: any
  • action_id: Hash
  • action: {}

Returns

  • DetectedGestures — A table containing detected gestures. Can contain the following values:
    • tap [table] Values: position
    • double_tap [table] Values: position
    • long_press [table] Values: position, time
    • repeated [boolean]
    • swipe_left [boolean]
    • swipe_right [boolean]
    • swipe_up [boolean]
    • swipe_down [boolean]
    • swipe [table] Values: from, to and time
    • two_finger [table] Two-finger geatures (tap, double_tap, long_press, repeated, swipe_* and pinch)

Variables

SETTINGS: { action_id: Hash; tap_threshold: number; double_tap_interval: number; swipe_threshold: number; swipe_time: number; long_press_time: number; multi_touch: boolean; }

Types

GestureInstance

GestureInstance.on_input(action_id: Hash, action: {}): DetectedGestures

Parameters

  • action_id: Hash
  • action: {}

Returns

  • DetectedGestures

DetectedGestures

DetectedGestures.tap?: { position: { x: number; y: number; }; }

DetectedGestures.double_tap?: { position: { x: number; y: number; }; }

DetectedGestures.long_press?: { position: { x: number; y: number; }; time: number; }

DetectedGestures.repeated?: boolean

DetectedGestures.swipe_left?: boolean

DetectedGestures.swipe_right?: boolean

DetectedGestures.swipe_up?: boolean

DetectedGestures.swipe_down?: boolean

DetectedGestures.swipe?: { from: { x: number; y: number; }; to: { x: number; y: number; }; time: number; }

DetectedGestures.two_finger?: { tap?: boolean; double_tap?: boolean; long_press?: boolean; repeated?: boolean; swipe_left?: boolean; swipe_right?: boolean; swipe_up?: boolean; swipe_down?: boolean; pinch?: { center: { x: number; y: number; }; ratio: number; }; }

On this page