Handmade Web Games

Getting Started

What is this?

Spud makes the browser Gamepad API more fun to use. Add it to your game loop for a simple way to read button presses from controllers, work with joysticks, trigger haptics, identify the controller layout, and much more. It's a lightweight wrapper that still allows for low-level control when you need it.

Installation

# with bun
bun add @spud.gg/api

# ... or the equivalent call to npm, pnpm, yarn, etc.

Features

  • Built-in analog stick deadzone handling with axial and radial normalization
  • Simplified wrappers for haptics
  • Simplified gamepad button handling
  • Utilities for snapping analog sticks to 4 or 8 directions
  • Gamepad layout and base model detection
  • Written with tree-shaking in mind

And a handful of optional utilities that aren't tied to the Gamepad API but can come in handy when you're making web games:

  • Easing functions for animations
  • Web Audio helpers for sound effects and music playback
  • Mouse and keyboard input handlers that well in game loops

On this page