Bash.tv → GitHub → itch.io

Vibration feedback for browser games on phones and controllers. Named patterns (tap, select, pickup, hit, heavy, explosion, success, error), a strength setting, an off switch, limits so buzzes don't pile up, controller rumble with strong and weak motors, the first-tap rule, stopping when the tab is hidden, and a visual fallback where vibration doesn't exist (iPhone, desktops); when haptics help...

Download skill (.zip) Files on GitHub

Haptic feedback

Where it works

Device Support
Android phones (Chrome, Edge, Samsung, Firefox) navigator.vibrate: on/off pulses, no strength control
iPhone and iPad (all browsers) None. Use a visual cue: screen shake, flash, a squash on the sprite
Controllers in Chrome and Edge Rumble with strong (heavy) and weak (buzzy) motors
Desktop browsers None for the device itself

So haptics are always extra: the game must feel complete without them.

assets/haptics.js

import { createHaptics, stopWhenHidden } from "./haptics.js";
const haptics = createHaptics({ pads, strength: settings.get("vibration"), onFallback: (name) => camera.shake(name === "heavy" ? 6 : 3) });
stopWhenHidden(haptics);
haptics.play("hit");                       // phone vibration
haptics.play("heavy", { pad: 0 });          // controller 0 rumble (gamepad-support's pads)
haptics.play([15, 30, 15]);                 // your own pattern: on, off, on (ms)
settings.on("vibration", (v) => (haptics.strength = v));   // 0 = off, 0.35..1 shortens pulses on phones

When to buzz

Tested

Node tests: patterns, rate limiting, strength shortening pulses (pauses unchanged) with a minimum, off switch, the first-tap rule, the fallback when there’s no vibration, controller rumble scaled by strength, custom and unknown patterns. Try it on Android and with a controller in the device lab (cross-browser-compatibility).

Pitfalls

Relying on vibration for information, buzzing constantly, ignoring the setting for controllers, vibrating while the tab is in the background, and forgetting iPhone players get nothing (use the fallback).