Bash.tv → GitHub → itch.io

Accessibility Manager

Player accessibility preferences in one place (reduced motion, screen shake, flashing, high contrast, text size, colour-blind safe colours, subtitles, hold or toggle) that start from the device’s settings, are saved, and can be read out to screen readers.

Files: accessibility-manager.js (the component, no dependencies) and accessibility-manager.test.mjs (4 tests). Copy accessibility-manager.js into your game, for example to src/components/, and import it as an ES module.

Usage

import { createAccessibility } from "./accessibility-manager.js";
const a11y = createAccessibility({ key: "my-game:a11y" });
a11y.apply(document.documentElement);                // CSS classes and --text-scale for HTML menus
camera.shakeScale = a11y.get("screenShake") ? 1 : 0;
a11y.onChange((k, v) => { if (k === "screenShake") camera.shakeScale = v ? 1 : 0; });
const colors = a11y.palette();                       // team or key colours that stay distinct for colour-blind players
a11y.announce("Level 2. Find the key.");             // screen reader message

API

The device’s settings are only used for values the player hasn’t changed.

Engines

Engine Notes
Vanilla, Phaser, PixiJS, Three.js yes. Read the values where effects are made: camera shake, particles, flashes, fonts, colours.

Tests

Node tests: device settings as starting values, player choices win and are saved, ranges, palettes, text size, apply() classes, announce() with a fake document.

Run them with node --test toolkit/components/accessibility-manager/ (Node 20 or newer, nothing to install).