Skip to content
animorio
IT
All components

Search shortcut button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.0 KBGSAP 28 KBFreeDownload the zip

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.

The code

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>

Playground

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

Or ask your AI assistant for it

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 site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

In the middle of a very light grey background sits a white pill with a wide soft shadow: on the left the line-drawn lens, then «Search docs…» in grey, on the right two small raised keys, Ctrl and K, with a lighter top edge like the light on the keys of a real keyboard and their small shadow below. Hovering lifts the keys by a pixel, one after the other, their shadow lengthens and the lens turns a few degrees. Pressing the button squashes the pill slightly and it comes back with a small bounce, and the two keys go down into their base, Ctrl first and then K ninety milliseconds later, squashing their shadow, then come back up on a spring. Meanwhile the pill widens to four hundred pixels, past and back, and lights up with a thin blue ring; Ctrl and K shrink and fade, and the Esc key arrives in their place. The text stays, with a blinking blue caret, and below a card opens with «Suggested» and two items, Getting started and Scroll-triggered animations, rising one after the other. Typing makes the caret nudge at every letter and the grey band settles on the item that contains the word. Esc presses down too and everything closes with the same spring; a click outside closes it as well. The shortcut really works: Ctrl K, or Cmd K, pushes the keys down and opens the field. A drawn pointer does it all by itself: it presses, types «scroll», moves to the item, closes with Esc, then opens again with the shortcut alone and closes by clicking outside.

How it works

A key made of two parts

Each 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.

One after the other

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.

The pill that widens

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 caret and the band

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.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f6bffThe colour of the open field’s ring and of the caret.
PLACEHOLDERscript.jsSearch docs…The text of the closed pill.
QUERYscript.jsscrollThe word the autopilot types.
OPEN_WIDTHscript.js400How wide the open pill gets, in pixels.
KEY_TRAVELscript.js2.5How many pixels a pressed key goes down.
KEY_GAPscript.js0.09The seconds between the first key and the second.
BOUNCEscript.js1.5How much the pill bounces when it opens and closes.
SPEEDscript.js1Speed of everything: 2 twice as fast, 0.5 half as fast.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • The keycap moves with a CSS variable rather than a GSAP transform: that way a single translateY carries both the press and the lift, and the base’s shadow follows them without a second tween.
  • The open width is written in pixels and must be removed on closing (empty style.width): otherwise the closed button would no longer fit its text or the resize.
  • Ctrl K must be stopped with preventDefault, or the browser opens its own search bar.
  • The ring’s soft colours are computed in the script from the accent: not every video recorder reads color-mix.

Libraries

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.

Testing

Tested on 26 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

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.

All components