How a keyboard sound app works

Updated

A keyboard sound app asks macOS for a copy of every key event, picks a sound for the key that moved, varies it slightly so no two presses match, and plays it through your Mac's output. Here is each step as Teclo does it, from its source code.

1-day free trial · $4.99 once · up to 3 Macs · macOS 13+

Secure checkout, payments byStripe· 14-day refund, no questions asked

1. Hearing the key

Once you allow it under Input Monitoring, Teclo creates an event tap: a request to macOS for a copy of certain events on your login session. Teclo asks for key presses, key releases and modifier keys, plus mouse buttons, scrolling and trackpad gestures for its other sounds.

The tap is listen-only. macOS hands Teclo a copy of each event and passes the original on unchanged, so Teclo cannot block, change or add a keystroke. What the permission allows is covered in Input Monitoring on a Mac, and what it means for privacy in is a keyboard sound app safe?.

Two things can stop the copies arriving. Secure Input, turned on by password fields and some terminals, holds back key events from every app (Secure Input on a Mac). And macOS switches off a tap whose app is too slow to answer; Teclo watches for that notice and switches its tap straight back on.

2. Choosing a sound

Each key event carries a key code, a number for the physical key. Teclo uses it three ways:

A held key plays again on every key repeat. Modifier keys sound too, unless “Silence modifier keys” is ticked.

3. Making each press different

One file on every key gets old fast; as one Reddit user put it about another app, “all letter key sound the same. That will make it repetitive and boring real fast”. Teclo varies every press three ways:

Variation Range Applies to
Level Up to 1.5 dB up or down, at random Press and release
Pitch Up to 10 cents up or down, in five steps Press only
Stereo position Up to 0.35 left or right, by the key’s place Press and release, except Space

The pitch range is kept small on purpose. When pitch variation was added to Thock, another Mac app, its maintainer settled on ±10 cents: “10 is honestly the max i can tolerate”.

4. Playing it

Teclo plays through Apple’s AVAudioEngine at 48 kHz in stereo. Four choices in its code keep a key press from waiting:

After a minute without a sound, Teclo lets the audio engine stop so the output device can sleep, and starts it again on the next key.

5. Reaching your ears

The sound goes to the Mac’s current output device. Built-in speakers and wired headphones add little; Bluetooth headphones add a delay no app can remove (why typing sounds lag over Bluetooth).

Where the sounds come from

That chain is the same whether an app plays recordings of a real keyboard or sounds it synthesized. Teclo’s are synthesized; Klack’s and Kiiwi’s are recordings. Synthesized or recorded keyboard sounds compares the two.

Questions

Does a keyboard sound app see what I type?

It sees which key moved, because macOS hands it the key event. Teclo uses the key's code only to pick a sound and a stereo position, and keeps no record of keys or text.

Why does every key sound slightly different?

Teclo gives ordinary keys five different sounds and Space, Return and Delete their own, then varies each press's level by up to 1.5 dB and its pitch by up to 10 cents.

Why does a keyboard sound app need Input Monitoring?

macOS only passes key events from other apps to an app the user has allowed under Input Monitoring. Without it, the app is never told a key moved.

Sources

Other facts on this page come from these pages, read on or before the date above.

Teclo

Launch price$4.99· $9.99 from 1 December

One-time · 1-day free trial · 14-day refundDownloadBuy · $4.99