Skip to content
IndexRequest a UIAboutContact

Keycap Press Travel

Four keys that sink when pressed, with travel and key style controls; real keyboard keys work too.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Product photograph of a row of four mechanical keyboard keycaps with letters A S D F in a warm cream and charcoal colourway, the second key pressed halfway down so its top face sits lower and the side wall almost disappears, crisp edges, matte PBT texture, soft top light, shallow depth of field, neutral background, tactile and precise. Variants: low-profile laptop keys with shallow travel, soft rounded keys. Negative: glossy plastic, RGB lighting, text errors, hands, clutter. Reduced motion: static image with one key darker.

About this pattern

Definition

A keycap feels real when it moves: the top sinks toward the base and the side wall shrinks while the key is down, then it springs back. The amount of travel and the speed of the return are what distinguish a deep mechanical key from a shallow laptop key.

Purpose & UX principles

  • Draw the key as a top face on a darker base; on press, move the top down by the travel amount and reduce the base shadow to nothing.
  • Mechanical keys: deep travel, snappy return; laptop keys: shallow travel; soft keys: deep, slow return.
  • Support real key presses as well as pointer presses.

Interaction states

  • Three key styles, a Travel slider, and four keys that respond to pointer and to the matching keyboard letters.

Motion specification

  • Press: 40ms down; release: 140ms up (mechanical), 90ms (laptop), 260ms (soft).
  • Reduced motion: the key shows a darker colour while pressed instead of moving.

Responsive behaviour

  • Make each key at least 44px for touch.
  • Do not rely on the animation alone; show the typed result as well.

Code

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Key style"><button data-p="0" aria-pressed="true">Mechanical</button><button data-p="1" aria-pressed="false">Laptop</button><button data-p="2" aria-pressed="false">Soft</button></div><div class="kb" id="kb"><button class="k" data-k="a" type="button">A</button><button class="k" data-k="s" type="button">S</button><button class="k" data-k="d" type="button">D</button><button class="k" data-k="f" type="button">F</button></div><label class="rw">Travel <b id="tv">8px</b><input id="tr" type="range" min="2" max="12" value="8"></label><p class="out" id="out" aria-live="polite">Press a key, or type A S D F.</p></div>

Related patterns

Soft Rubber Squish

↗
Soft Rubber SquishSurfaces & Objects

Soft UI Raised & Pressed

↗
Soft UI Raised & PressedGlass & Tactile

Liquid Glass Button

↗
Liquid Glass ButtonGlass & Tactile