New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@0xsharon/click-clack

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsharon/click-clack

Satisfying, procedurally synthesized mechanical keyboard audio feedback for web apps. Zero audio files, under 2KB minified.

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
23
-36.11%
Maintainers
1
Weekly downloads
 
Created
Source

click-clack ⌨️

Satisfying, procedurally synthesized mechanical keyboard audio feedback for web apps.
Zero audio files, under 2KB minified, pure Web Audio API acoustics.

npm version bundle size GitHub license

⚡ Features

  • 🎹 Zero Audio Files: No 500KB MP3/WAV assets to load. 100% procedurally synthesized in real-time.
  • 🪨 Authentic Switch Acoustics:
    • thock — Deep, lubed tactile/linear mechanical switches (Holy Panda / Topre feel).
    • clicky — Crisp click-leaf with metallic spring resonance (Cherry MX Blue / Kailh Box White).
    • typewriter — Heavy steel mechanical typewriter with hollow chamber resonance.
    • bubble — Modern playful UI pop sound.
  • 🎛️ Spacebar & Stabilizer Emulation: Heavy keys (Spacebar, Enter, Backspace) automatically have specialized acoustic weighting and stabilizer wire acoustics.
  • 🎲 Anti-Machinegun Jitter: Organic pitch and gain jitter (±4%) prevents repetitive robotic machine-gun effect during fast typing.
  • ⚛️ First-Class React Hook: Native useClickClack support included.
  • 📦 Dual ESM / CJS & Full TypeScript: Works everywhere in modern bundlers (Vite, Next.js, Remix, Astro).

📦 Installation

npm install @0xsharon/click-clack
# or
pnpm add @0xsharon/click-clack
# or
yarn add @0xsharon/click-clack

🚀 Quick Start

1. Vanilla JavaScript / TypeScript

Attach mechanical switch acoustics to any <textarea>, <input>, or the entire window:

import { attachMechanicalAudio } from '@0xsharon/click-clack';

// Attach to an editor or input
const unsubscribe = attachMechanicalAudio(document.querySelector('#editor'), {
  profile: 'thock',     // 'thock' | 'clicky' | 'typewriter' | 'bubble'
  volume: 0.8,          // 0.0 to 1.0
  playRelease: true     // Plays softer upstroke reset sound on keyup
});

// Later, teardown when needed:
unsubscribe();

2. Manual Audio Triggers

Trigger clicks anywhere in your application (buttons, menus, shortcuts):

import { playSwitch } from 'click-clack';

// Play on button click
button.addEventListener('click', () => {
  playSwitch({ profile: 'clicky', volume: 0.9 });
});

// Play spacebar stabilizer sound
playSwitch({ profile: 'thock', key: ' ' });

⚛️ React Integration

Import directly from click-clack/react:

import React, { useRef } from 'react';
import { useClickClack } from 'click-clack/react';

export function CodeEditor() {
  const textareaRef = useRef<HTMLTextAreaElement>(null);

  // Automatically binds keydown & keyup acoustics to this element
  useClickClack(textareaRef, {
    profile: 'thock',
    volume: 0.8
  });

  return (
    <textarea
      ref={textareaRef}
      placeholder="Type to feel the switches..."
    />
  );
}

Or enable mechanical sound across the entire browser window:

import { useGlobalClickClack } from 'click-clack/react';

export function App() {
  useGlobalClickClack({ profile: 'thock', volume: 0.7 });
  return <div id="app">...</div>;
}

🎛️ API Reference

attachMechanicalAudio(target, options)

Binds event listeners to target (HTMLElement | Window | Document). Returns an unsubscribe cleanup function.

OptionTypeDefaultDescription
profile'thock' | 'clicky' | 'typewriter' | 'bubble''thock'Switch acoustic profile
volumenumber0.8Master volume (0.0 - 1.0)
playReleasebooleantrueSynthesize release click on keyup
filter(e: KeyboardEvent) => booleanundefinedOptional key filter function

playSwitch(options)

Plays a one-off synthesized mechanical switch sound.

OptionTypeDefaultDescription
profileSwitchProfileActive profileProfile signature
volumenumber1.0Relative volume
pitchnumber1.0Base pitch multiplier
isReleasebooleanfalseTrue for upstroke reset sound
keystring | KeyRole'standard'Key character (e.g., ' ' for Spacebar)

createSwitchEngine(defaultOptions)

Creates an isolated controller instance with .play(), .setProfile(), and .setVolume() methods.

🎧 Interactive Playground

To try the sound profiles locally in your browser, open demo.html in any browser or launch a local preview server!

📄 License

MIT © 0xSHARON

Keywords

mechanical-keyboard

FAQs

Package last updated on 12 Oct 2026

Related posts