Skip to content
animorio
IT
Back to the library

Mechanical keyboard

3D, Hover, TextGSAP, CSS onlyMediumCompressed weight: Demo 5.3 KBGSAP 28 KBFreeDownload the zip

The opening of an invented keyboard shop: under the headline sits a compact mechanical keyboard, tilted back in perspective, and the headline types itself while the right keys travel down, spring back up and leave an orange glow underneath. On hover the keys lift slightly, and you can type by hand, on your real keyboard or by tapping the keys.

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>
<!--
  "Mechanical keyboard" 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 mechanical keyboard that types the headline</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">
    <!-- the opening of a keyboard shop: the headline types itself on the keyboard below, key by key -->
    <section class="hero" data-hero aria-label="Keymoor, mechanical keyboards">
      <p class="hero__brand"><svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2.5" y="5.5" width="15" height="9" rx="2.4"></rect><path d="M6 8.6h1.6M9.2 8.6h1.6M12.4 8.6h1.6M7.2 11.4h5.6"></path></svg><span>Keymoor</span></p>
      <h1 class="hero__title" aria-live="polite"><span class="hero__text" data-text></span><span class="hero__caret" data-caret aria-hidden="true"></span></h1>
      <p class="hero__sub" data-sub>Hot-swappable 65% boards, switches lubed by hand.</p>
      <div class="hero__cta">
        <a class="hero__btn" href="#" data-btn>Shop keyboards</a>
        <span class="hero__note">Ships in 48h</span>
      </div>
      <div class="desk" data-desk>
        <div class="board" data-board aria-hidden="true">
          <div class="board__plate" data-plate></div>
        </div>
        <div class="board__shadow" aria-hidden="true"></div>
      </div>
      <p class="hero__hint" data-hint>Type anything</p>
    </section>
  </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.

22 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 “Mechanical keyboard” 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

On a very light warm grey background, at the top is the white pill of the Keymoor brand with its small drawn keyboard, then the big headline, a line in grey, the black «Shop keyboards» button and «Ships in 48h». Below, a compact 65 per cent keyboard, with a grey case and white keys, tilted back in perspective as if it sat on the desk; esc and return are orange. The headline types itself, one letter at a time, with the uneven rhythm of a real hand: for each letter its key goes down with real travel, its side shortens and its shadow tightens, then it springs back up, and under the key an orange glow lights up for a moment. For capitals, shift goes down too. Each letter arrives in the headline rising by a hair, and after the last one the orange cursor blinks. The headline holds, then delete wipes it quickly and the next one arrives: «Type like you mean it.», «Every press, felt.», «Built to be heard.». With the pointer over it, every key lifts a little and drops back on an elastic; typing on your real keyboard or tapping the keys makes the headline yours, and after eight quiet seconds the loop starts again.

How it works

A keyboard made of divs

The layout is a list of rows in key units (13 wide): the script makes one div per key, places it in pixels worked out from the width and height of the window and redoes it on resize. The whole plate lives in an element tilted with rotateX inside a container with perspective.

Travel with two variables

Each key has two CSS variables, --p for the press and --h for hover: the CSS uses them to move the keycap and to shorten the side made of box-shadow, so GSAP only animates two numbers and never touches the CSS transform.

The spring and the glow

Pressing means taking --p to 1 in 45 milliseconds with power2.out and bringing it back to 0 with elastic.out(1, 0.45); at the same time a radial orange halo under the key lights up and fades in six tenths.

The rhythm of a hand

The pilot is a repeating timeline with one call per letter: the gap between letters varies with a fixed-seed generator, spaces are a little longer, and every loop matches the previous one, so preview and video agree.

Your hands

A keydown on the page or a tap on a key stops the pilot and the headline becomes what you type, with delete, return and esc doing their job; after eight seconds without keys the pilot starts over.

Values to change

NameFileDefaultWhat it changes
HEADLINESscript.js'Type like you mean it.|Every press, felt.|Built to be heard.'The headlines the keyboard types one after another, separated by |.
TYPE_SPEEDscript.js9How many letters per second the pilot types.
HOLDscript.js1.6The seconds the finished headline holds before it is deleted.
DELETE_SPEEDscript.js26How many letters per second the delete key removes.
TRAVELscript.js0.8How far a pressed key goes down, relative to its height.
TILTscript.js38How far the keyboard tilts back, in degrees.
ACCENTscript.js'#ff5a36'The colour of the cursor, the glow under the keys and the esc and return keys.

Try them in the Playground

When to use it

For the opening of a keyboard or accessories shop, or a writing app, or any headline that should feel typed right now: the keyboard shows the product and writes the message at the same time.

On phones

The same animation with adapted sizes: the key unit is worked out from the width and height of the box, the headline stays on one line with a size tied to the screen and the «Ships in 48h» line goes away. The keys respond to the finger and type the headline; the hint below says «Tap the keys».

With reduced motion

No typing and no keys going down: the first headline is already written, the cursor is still, and pressing a key only lights the glow underneath.

Pitfalls

  • The keycap moves with calc on the --p and --h variables inside the CSS: GSAP animates the variables on the key element and not the transform, which would wipe the class transform.
  • The pixel sizes of the plate and the keys are recomputed on resize, because the demo window changes height while you watch it.
  • The arrows on the keys are drawn SVG: arrow characters can turn into emoji on iPhone.
  • The pilot’s rhythm uses a fixed-seed generator and not Math.random, so the preview video and the live loop are the same.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.3 KB; the libraries: GSAP 28 KB.

Testing

Tested on 28 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 animations