All motions

A keystroke in cross-section

Explainer: mechanical switch, force–travel plot and the signal all the way to the letter

Created with AI
  1. 0–4.2 s The key row from above, section line A–A, then the camera tilts into the front view and a wipe cuts the J key open
  2. 4.2–9 s Exploded view — keycap, stem, top housing, spring, contact leaf, bottom housing and circuit board with leader lines
  3. 9–12.4 s The press in slow motion — the spring compresses, the contact closes at 2.0 mm and 45 cN, bottom-out at 4.0 mm and 60 cN
  4. 12.4–15.7 s The signal — the contact bounces, the controller waits 5 ms, one clean edge remains, a j appears on the screen
  5. 15.7–20 s Release — the spring pushes the stem back, the section closes, the camera tilts back to the row
  • Explainer
  • 20 s Loop
  • 1080² · 30 fps
  • Canvas 2D
  • 800 KB

Prompt

English · for Claude Code, Codex & co. · 926 words
Build a 20-second looping explainer, 1080×1080: "What happens in a keystroke" — one mechanical key switch from the keycap to the letter on screen, as a flat technical illustration with fine depth, not clip art. All on-screen text comes from one small dictionary; ?lang=de switches to German. No brand names.

DESIGN
Cool paper #ECEEF2, ink #1A212C, muted #6F7A89, one accent: vermilion #EE4F2B (stem, force arrow, live point, signal, the J legend). Everything is modelled in millimetres (z up, plate top = 0): a generic linear switch with 4.0 mm travel, 30 cN preload and 7.5 cN/mm, so 45 cN at the 2.0 mm actuation point and 60 cN at bottom-out. Cut surfaces are flat fills with a 1.6 px ink outline, the far walls behind the cut plane a lighter tone of the same part: keycap white, top housing light grey, bottom housing slate, plate and circuit board dark, spring and contacts steel. Geist for title, labels and captions, Geist Mono for every number, kicker and axis. Fixed chrome: kicker and title top left, a view label top right ("TOP VIEW" / "SECTION A–A"), bottom left "0n / 05" with the scene name and a two-line caption that breaks at the sentence end, bottom right five progress segments.

STORYBOARD
0–4.2 s  Top view of a five-key row (G H J K L, homing bar on J) on a dark board with a soft shadow. The J legend turns accent, a dash-dot section line A–A draws across the row with arrows and letters. The orthographic camera tilts 90° around the middle of the switch into the front view while zooming in; legends foreshorten and fade. A vertical accent line wipes the front half of the J key away and reveals the section; then the neighbours slide out of frame sideways, opaque and staggered, outer keys first.
4.2–9 s  Exploded view: keycap, stem, top housing, spring (relaxing to its free length), contact leaf (off to the left, closing because nothing holds it open), bottom housing with plate, circuit board. Leader lines grow from a dot on each part to a label column, staggered top to bottom. Labels retract, the parts reassemble while the camera zooms in and moves the switch to the left.
9–12.4 s  The press in slow motion. A force arrow appears above the cap, the stem travels 4.0 mm, the spring coils close up, the leg on the stem lets the contact leaf swing onto the fixed contact at exactly 2.0 mm (accent ring, then a steady dot). On the right a force–travel plot draws in sync: 0–4 mm, 0–80 cN, live readouts, marked actuation point (2.0 mm · 45 cN) and bottom-out (4.0 mm · 60 cN) with a dashed hard stop.
12.4–15.7 s  The plot becomes a scope on the same axes: the curve runs back to the origin, tick labels change from mm to ms. A trace grows from the switch pin to a controller chip and on to a small screen. The raw contact signal draws with a short jagged edge while a broken pulse runs down the trace; a 5 ms bracket appears, the chip's bar fills, everything inside the window sinks to low and one clean accent edge remains; a solid pulse runs to the screen and "j" appears beside the cursor.
15.7–20 s  Release: the spring pushes the stem back, the contact opens, scope, chip and screen retract. The camera pulls back, the neighbours slide back in, inner keys first, the wipe closes the key from the left, the camera tilts back to the top view; caption 1 and the empty progress bar are back before the loop point.

MOTION
The row is a set of solids (rounded rings joined by quad strips, shaded by their normal, culled against the view direction) projected with one tilt angle, so top view, front view and everything between are the same geometry. The section is drawn in the same millimetres, so the wipe matches the silhouette exactly. Spring: a projected helix with closed end coils, back half-turns behind the stem rod, front half-turns in front; its length is seat minus floor. The contact leaf rotates about its root as a function of travel only. Camera moves use smootherstep, zoom is interpolated in log space, parts and camera share one curve so nothing runs ahead of the zoom; arrivals use critically damped springs normalised to land exactly on 1. No text changes during a camera move.

TECHNIQUE
- One self-contained HTML page plus one JS file (no inline script, no libraries, no network requests). Stage exactly 1080×1080 CSS px, or the size named above (1080×1920 for portrait).
- Expose window.MOTION = { duration, fps: 30, width, height, seek(t) } with the stage size in width and height. seek(t) redraws the frame for time t from scratch: no state between frames, no Math.random (seeded PRNG only), no Date, no CSS transitions, no timers.
- Loop: seek(0) and seek(duration) must look identical.
- With ?render=1 the stage sits unscaled at the top left (for frame capture). Without it, scale the stage to fit the window and loop with requestAnimationFrame.
- prefers-reduced-motion: show one representative still, no loop.

CHECK
Render stills at the listed times, look at every one, fix anything that overlaps, is cut off, aliased or unreadable, then render again. Report only when frame 0 equals the last frame.
Stills: every 0.5 s, every 0.1 s around 2.0–5.9, 7.6–9.9, 12.3–13.2, 14.4–15.1 and 16.9–19.9, plus 2× crops of the section at 9.4, 10.9 and 12.2, in both languages; frame 0 must equal frame 19.97.

How to recreate it

  1. Give the prompt to a coding agent

    Create an empty folder and paste the prompt into Claude Code, Codex or Cursor. The agent writes one HTML page and one script — the animation then runs right in the browser.

  2. Let it check the stills

    The prompt makes the agent render stills and look at them itself. Only refine what you don't like in the picture: “scene 3 is too busy” works better than a new prompt.

  3. Render to MP4

    Because every animation can draw any frame exactly through window.MOTION.seek(t), a small script renders it frame by frame — no stutter, no screen recording. Then ffmpeg joins the frames into a clip.

Render commands Download render.mjs
# 1 · Render every frame (Chrome, Node ≥ 22)
node render.mjs http://localhost:3000/ \
  frames/ frames 30

# 2 · Join the frames into an MP4
ffmpeg -framerate 30 -i frames/%05d.png \
  -c:v libx264 -preset slow -crf 22 \
  -pix_fmt yuv420p -movflags +faststart \
  my-motion.mp4

How a clip is built with Claude Code

Background

What happens in a keystroke, as a technical illustration: the camera tilts from the key row into the section of one switch, shows its seven parts exploded and then the press in slow motion. The spring compresses, the contact leaf closes at 2.0 mm, a force–travel plot runs in sync, the signal is debounced and appears as a letter. 20 seconds, English and German, with the prompt.

What I learned building it

I built the switch once in millimetres and derived everything from it: top view, section, spring length and plot. That is why the contact closes in the picture exactly where the curve marks its actuation point. Transitions feel calmer when parts and camera follow the same curve.

Inspiration

The starting point was a prompt by @iniyanai ((opens in a new tab)) on Skillry. You'll find the original wording there; the prompt above is my own version.

More motions

Contact

Let's discuss
your project
together.

Send me a message or fill out the contact form. I'll get back to you within 24 hours.

Paul Mill

Paul Mill

hallo@paulmill.com