Zero-dependency procedural Web Audio API synthesizer for mechanical keyboard switch acoustics (thock, clack, clicky, creamy, marbly, holy-panda, typewriter, silent-tactile).
Extracted from Keyboard Cheat Codes (keyboardcheat.codes). Play realistic mechanical keystroke sounds in any web app, typing trainer, or terminal portfolio with 0 KB of audio file downloads.
- Zero Audio Assets: 100% procedural synthesis via Web Audio API oscillators and bandpass filters.
- 8 Built-in Switch Profiles:
thock,clack,clicky,creamy,marbly,holy-panda,typewriter, andsilent-tactile. - Key-Size Acoustic Scaling: Stabilized keys (
Space,Enter,Shift,Backspace) automatically shift to deeper housing resonance frequencies. - Natural Micro-Jitter: Subtle per-keystroke pitch randomization prevents robotic repetition.
- TypeScript Ready: Ships with full
.d.tstype definitions.
npm install mech-switch-synthimport { createSwitchSynth } from "mech-switch-synth";
const synth = createSwitchSynth({
defaultPreset: "thock",
volume: 0.7
});
window.addEventListener("keydown", (event) => {
if (!event.repeat) {
synth.triggerKeydown({ key: event.key });
}
});
// Switch acoustic profile dynamically:
synth.setPreset("creamy");We welcome community contributions for new mechanical switch presets (e.g., cherry-mx-brown, gateron-oil-king, topre-45g, alps-blue, buckling-spring)! Add an entry to SWITCH_PRESETS in index.js and run npm test.