Play a click sound on keyboard key presses (Linux evdev + miniaudio).
- Linux with evdev (
/dev/input/event*) - Build:
gcc,libpulse-dev(PipeWire/PulseAudio playback) - User in the
inputgroup (log out/in aftersudo usermod -aG input "$USER")
curl -fsSL -o miniaudio.h \
https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
mkdir -p ~/.local/share/keysound/soundpack
# Put the Mechvibes pack files there (concatenated_audio.wav + config.json).The per-key timings in keymap.c match one specific pack (its config.json). A different pack needs a regenerated table.
gcc -Wall -Wextra -o keysound keysound.c keymap.c -lpthread -ldl -lm -lpulse./keysound [-d soundpack_dir] /dev/input/eventN-d sets the folder that holds concatenated_audio.wav (default: ~/.local/share/keysound/soundpack).
Find the device: sudo apt install evtest && sudo evtest - pick your keyboard.
keyd: if the physical keyboard is grabbed, use the keyd virtual keyboard node instead (often /dev/input/event11). Check with evtest.
Do not run with sudo - audio goes to your user session.
keysound.cenables miniaudio's PulseAudio backend so audio routes to normal desktop output (not silent HDMI ALSA).- Sound packs from mechvibes.com are third-party; keep them out of git.
MIT