TapTickit Docs

TapticKit

Class exported from taptickit. Implements vibration via navigator.vibrate when supported, with optional DOM + audio fallback for development.

Constructor

new TapticKit(options?: TapticKitOptions)

TapticKitOptions: debug?, showSwitch?.

Static

NameTypeDescription
isSupportedbooleantrue when navigator.vibrate is a function

Methods

trigger(input?, options?)

trigger(
  input?: HapticInput,
  options?: TriggerOptions,
): Promise<void>

Plays a pattern derived from input:

  • Default — single medium tap: [{ duration: 25, intensity: 0.7 }]
  • String — named preset from defaultPatterns (e.g. "success")
  • Number — milliseconds for one pulse
  • Array[on, off, on, …] numbers or Vibration objects
  • Object — custom { pattern: Vibration[] } preset shape

TriggerOptions: intensity? (0–1) scales default intensity per segment when individual vibrations omit intensity.

Durations are clamped to a safe window for the Vibration API. Invalid values log a warning and no-op.

cancel()

Stops the internal animation loop and calls navigator.vibrate(0) when supported.

destroy()

Tears down DOM nodes (accessibility label / switch) and closes any AudioContext opened for debug.

setDebug(debug: boolean)

Enables or disables debug mode; disposes audio when turning off.

setShowSwitch(show: boolean)

Shows or hides the injected switch UI.