
The elastic button
Buttons, Hover, Text
The documentation search button of a product, in the style of today’s micro-interactions, on very light grey: a white «Search docs…» pill with two real raised keys, Ctrl and K. On hover the keys lift by a pixel and the lens turns slightly; pressing the button, or the real shortcut on the keyboard, pushes the two keys down one after the other, squashing their shadow, and the pill springs open into a field with a blinking caret, a blue ring and two suggestions rising below. Esc, which has meanwhile taken the place of the two keys, presses down too and closes it again.
A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.
<!doctype html>
<!--
"Search shortcut button" from Animorio · https://animorio.com
License: free on your own sites and your clients’ sites, paid work included.
Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Search button whose shortcut keys press down</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="stage" data-stage>
<!-- a docs search button with two real keycaps: hover lifts them, pressing the button or Ctrl K pushes them down one after
the other, then the pill widens into a field with a blinking caret and two suggestions; Esc or a click outside closes it -->
<div class="search" data-search role="search">
<div class="pill" data-pill>
<svg class="lens" data-lens viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.2"></circle><path d="m15.2 15.2 4.6 4.6"></path></svg>
<span class="pill__field">
<span class="pill__ph" data-ph>Search docs…</span>
<span class="pill__typed" data-typed aria-hidden="true"></span><span class="caret" data-caret aria-hidden="true"></span>
<input class="pill__input" data-input type="text" autocomplete="off" spellcheck="false" aria-label="Search docs" tabindex="-1">
</span>
<span class="keys" data-keys aria-hidden="true">
<span class="key key--wide" data-key-ctrl><span class="key__cap">Ctrl</span></span>
<span class="key" data-key-k><span class="key__cap">K</span></span>
</span>
<span class="keys keys--esc" data-esc-wrap aria-hidden="true">
<span class="key key--wide" data-key-esc><span class="key__cap">Esc</span></span>
</span>
<button class="pill__hit" type="button" data-hit aria-label="Search docs (Control K)" aria-expanded="false"></button>
</div>
<div class="sugg" data-sugg aria-hidden="true">
<p class="sugg__label" data-row>Suggested</p>
<div class="sugg__list">
<span class="sugg__mark" data-mark></span>
<a class="sugg__row" href="#" data-row data-item tabindex="-1">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 3.5h7l4 4V20a.5.5 0 0 1-.5.5h-10A.5.5 0 0 1 7 20V3.5Z"></path><path d="M14 3.5V8h4M10 12h5M10 15.5h5"></path></svg>
<span class="sugg__name">Getting started</span><span class="sugg__tag">Guide</span>
</a>
<a class="sugg__row" href="#" data-row data-item tabindex="-1">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 7 4 12l4 5M16 7l4 5-4 5"></path></svg>
<span class="sugg__name">Scroll-triggered animations</span><span class="sugg__tag">API</span>
</a>
</div>
</div>
</div>
<!-- an invisible box as big as the open state (wide pill and suggestions): the preview frames this -->
<div class="inquadra" data-inquadra aria-hidden="true"></div>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="script.js"></script>
</body>
</html>Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.
26 values to change
With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:
Take “Search shortcut button” from Animorio and fit it into my siteEach key is a grey base with the white cap inside, three pixels shorter: the part left visible underneath is the key’s thickness. Two CSS variables, --press and --lift, move the cap with translateY and change the base’s shadow at the same time, so GSAP animates two numbers and the drawing follows.
The shortcut is a small timeline: Ctrl goes down in 70 milliseconds, K ninety milliseconds later, the field opens while K is down, then the two keys come back up with back.out(3.2) in the same order. It is the same for a click on the button and for Ctrl K on the keyboard.
Before opening, the pill measures its natural width; then it goes from that to four hundred pixels (never more than the page minus the margins) with back.out, and on the way back it returns there and clears the written width, so the closed button stays as wide as its text.
The typed text is a span next to the placeholder, with the drawn caret after it: it blinks with a stepped tween that restarts at every letter. The grey band under the right item is a single element moving to the item’s offsetTop on a spring.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #2f6bff | The colour of the open field’s ring and of the caret. |
PLACEHOLDER | script.js | Search docs… | The text of the closed pill. |
QUERY | script.js | scroll | The word the autopilot types. |
OPEN_WIDTH | script.js | 400 | How wide the open pill gets, in pixels. |
KEY_TRAVEL | script.js | 2.5 | How many pixels a pressed key goes down. |
KEY_GAP | script.js | 0.09 | The seconds between the first key and the second. |
BOUNCE | script.js | 1.5 | How much the pill bounces when it opens and closes. |
SPEED | script.js | 1 | Speed of everything: 2 twice as fast, 0.5 half as fast. |
For the top bar of a software’s documentation, a developer library, a team app or a technical blog: wherever readers use the keyboard and the shortcut should be shown, and pressed, on the button itself.
The pill drops to 48 pixels and the text to 14; when open it takes the page width minus the margins. A tap does what a click does, and the keys still press down, so the shortcut shows even where there is no keyboard.
No springs and no movement: the pill goes from closed to open without stretching, the keys darken slightly instead of going down, the suggestions fade in, the caret stays on without blinking and the drawn pointer stays hidden.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.0 KB; the libraries: GSAP 28 KB.
Tested on 26 October 2026
Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.