Trackpad Instrument — play music on your laptop trackpad with a melody pad and 16 drum pads

~/trackpad-instrument drum kit hand tracking piano ☕ Support me apps ← about me
// trackpad instrument · melody pad + drum pads · loop recorder · optional haptic buzz on a Mac
Trackpad Instrument — your laptop trackpad as a synth and a drum pad
Slide a finger across the pad to play melodies in a scale, switch to 16 drum pads and record a loop. The sound comes from your speakers. A web page cannot make the trackpad’s own haptic motor buzz, but with the free Mac helper it does: every note and hit is felt in the trackpad too. In Safari, press harder for louder.
ModeMelody pad
Note—
Scale / kit—
Forcenone yet
Hapticsoff
Loopstopped
EngineClick to start
Brightness, vibrato and attack apply to the melody sounds, tune, decay and drive to the drum kit. Echo is a dotted-eighth delay that follows the tempo.

Guide — play music on your trackpad in five steps

No download, no account and no samples. Works with a laptop trackpad, a mouse, a touch screen and the keyboard.
1Start the sound

Click or tap the pad. Browsers only allow sound after a click, so your first touch also starts the audio engine.

2Play a melody

In Melody pad mode, slide a finger from left to right to change the pitch. The vertical lines are the notes of the scale. Move up and down to open the filter. The Magnet setting decides how strongly your finger snaps to the scale.

3Hit the drums and record a loop

Switch to Drum pads: the pad becomes a grid of 16 drums. Click or tap a pad, or use the keys. Press Rec for a one-bar count-in and record your hits, or load a ready-made beat on the Beat tab and play a melody over it.

4Use scroll, pinch and force

Two-finger scroll changes the octave (up and down) and the key (left and right). Pinch changes the range. In Safari on a MacBook, click the pad and press harder for louder notes. On a touch screen you can play with several fingers at once.

5Make the trackpad buzz

A web page cannot reach the haptic motor, but a small free Mac helper can. Download it on the Haptics tab, run it in Terminal, tick Feel it on the trackpad and every note and drum hit is played on the trackpad motor too.

What you can play with

TRACKPADPointer, scroll and pinch

A laptop gives the page one pointer, plus scroll and pinch. That is enough for a surprising amount of music.

Slide
plays and bends the note under your finger
Click harder
louder (Safari, Force Touch trackpad)
Scroll up or down
octave up or down (tempo in drum mode)
Scroll sideways
key up or down
Pinch
zoom the pad: 1 to 4 octaves
KEYBOARDPlay without a trackpad

The same sounds from your computer keys.

Melody
Z..M and Q..P play notes, Shift+↑/↓ change octave
Drums
1-4, Q-R, A-F, Z-V are the 16 pads
Loop
Space plays or stops, [ ] change the tempo
Mode
` switches melody and drums, Esc stops all sound
TOUCH SCREENPhones and tablets

A touch screen gives the page every finger, so you can play chords and several pads at once.

Several fingers
one voice per finger in melody mode
Tap pads
hit near the centre for a harder hit
Apple Pencil
pressure sets the volume or hit strength
Landscape
gives you the biggest pad
HAPTICSFeel it in the trackpad

Optional, Mac only. A tiny helper program plays the notes on the trackpad’s haptic motor.

Needs
a Mac with a Force Touch trackpad and Python 3
Setup
download the helper, run it, tick the box
Browser
Chrome, Edge or Firefox (Safari may block it)
Safe
listens on your own computer only

Play music on your trackpad, in your browser

This free trackpad instrument turns the trackpad of your laptop (or the screen of a phone or tablet) into two instruments: a melody pad that works like an XY synthesizer or a theremin, and a grid of 16 drum pads. Every sound is generated live in your browser with Web Audio. There are no recordings and no sample libraries, nothing is uploaded, and there is nothing to install.

The idea comes from nospeaker, a small Mac program on GitHub that makes a MacBook trackpad play tones through its haptic motor. On this page the sound comes out of your speakers or headphones and the trackpad is the instrument you play. If you also want to feel the notes in the trackpad itself, there is an optional Mac helper, described below.

Why can’t a web page make the trackpad buzz?

A MacBook trackpad has no speaker, only a small haptic motor that gives you the feeling of a click. According to the nospeaker README, Apple’s public haptics API offers only a few fixed taps, so nospeaker uses a private macOS framework to play custom tones on the motor, and it needs a Force Touch trackpad. A browser has no access to that. As far as I know there is no web API that drives a laptop trackpad’s haptic motor: navigator.vibrate exists in some Android browsers for phone vibration, but not on desktop and not in Safari on iPhone. A web page on its own therefore cannot make the trackpad buzz.

Feel the notes: the Mac helper

What a page can do is talk to a program on your own computer. The trackpad-haptics helper is a single Python file that you download from the Haptics tab and run in Terminal. It listens on 127.0.0.1, which only your own computer can reach, and it only accepts connections from pages on jasperbernaers.com. While you play, the page sends it short messages: start a note at this pitch and strength, change it, stop it, or play a drum hit. The helper turns them into vibrations on the trackpad motor, using the same private macOS framework as nospeaker. Held notes are played as a series of short overlapping buzzes at the pitch of your finger, and drum hits are short bursts, with a different pitch and length for each drum.

What a browser can read from a trackpad

A web page does not see your fingers on a laptop trackpad. It sees one pointer, like a mouse, plus scroll and pinch gestures. That is why the instrument is built around a single moving point, and why you can play several fingers at once only on a touch screen.

InputLaptop trackpadTouch screenUsed for
Pointer positionOne pointerEvery fingerPitch and brightness, which pad you hit
Press forceSafari on a Force Touch trackpad: physically click, then press harder. Other browsers report none.Apple Pencil, or a screen that reports pressure. Most phones report none.Volume and hit strength
Two-finger scrollYes, as scroll eventsNot usedOctave, key and tempo
PinchYes: Ctrl+scroll in Chrome, Edge and Firefox, a gesture event in SafariNot usedRange of the melody pad
Several fingers at onceNo, the browser gives one pointerYesChords, several pads

The Trackpad tab shows live what your own device reports (pointer type, pressure, press force, scroll and pinch), so you can see what works on your hardware. Without press force the page plays at a fixed volume in melody mode, and in drum mode it uses where you hit the pad: the centre is a hard hit and the edge is a soft one.

The melody pad: pitch, scale and magnet

The horizontal axis of the pad is pitch. It spans 1 to 4 octaves, starting at the octave you choose. The vertical lines are the notes of the selected scale and key: the bright line is the root note, the dimmer lines are the other scale notes. You can pick major, natural minor, major and minor pentatonic, blues, dorian, mixolydian, harmonic minor, hirajoshi, whole tone, or chromatic.

The Magnet slider sets how strongly your finger is pulled to the notes of the scale. At 100% the pitch jumps from note to note, like a keyboard. At 0% the pitch is completely free, like a theremin or a slide guitar, and every note in between is possible. The Slide time slider sets how fast the pitch follows your finger. A minor pentatonic scale with the magnet at 75% is a safe place to start: every note you land on sounds right.

The vertical axis can control brightness (a filter that opens as you go up), vibrato depth or volume. Choose which one on the Pad tab. With Latch on, a note keeps sounding when you lift your finger, so you can leave a drone and play with the other controls.

The seven sounds

The drum pads and the loop recorder

The drum mode turns the pad into a 4 by 4 grid. The bottom row holds kick, snare, closed hat and open hat; above them are clap, rim, two toms, crash, ride, cowbell, shaker, two congas, clave and a zap. A closed hat chokes an open hat, as on a real kit. All drums are synthesised, with three kits (studio, TR style and lo-fi) and sliders for tune, decay and drive.

The loop recorder works like a simple beat machine. Press Rec and, after a one-bar count-in, your hits are recorded into a loop of 1, 2 or 4 bars at the tempo you set. With Quantise on, hits snap to the nearest sixteenth note. Press Rec again to add another layer, Undo removes the last layer. On the Beat tab you can also load a ready-made beat (rock, hip hop, house, trap, bossa nova or reggae), set the tempo with a tap, and then switch to the melody pad to play over it: the loop keeps running.

The loop records drum hits only. Melodies are played live over it.

Tips for a better sound

Privacy

Everything runs on your device. The page does not upload anything and does not record your playing. It stores your settings (sound, scale, kit, tempo, haptics on or off) in this browser only, under the key jb-trackpad. The loop you record is kept in memory and is gone when you close the tab. If you turn haptics on, the page connects to ws://127.0.0.1 on your own computer, and nothing leaves it.

Honest limits

The page itself cannot make the trackpad buzz: that needs the optional Mac helper, which is experimental. A laptop trackpad gives the page one finger, so this is a one-finger instrument unless you use a touch screen. Press force depends on Safari and a Force Touch trackpad, and the page was tested with a mouse and simulated touch, not with every trackpad. The sounds are synthesised and simple: they are good for jamming and sketching, not a replacement for a real synthesizer or a sample-based drum kit. There is no MIDI input or output on this page; for that, see the virtual drum kit and the virtual piano.

More music tools

Play a drum kit from a MIDI e-drum or pad controller with the virtual drum kit, play music in the air with the hand tracking instrument, or browse all music tools.