# Keyboard key preview tooltip

> A phone keyboard where each key grows upward into a balloon with a large letter when pressed or focused.

- Category: [Tooltips](https://library.aimran.es/components/tooltips)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tip-key-preview
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A dark phone style keyboard with a Spanish layout, Ñ included, and a message field above it. Hover, focus or press a key and it grows upward into the familiar balloon with the letter shown large, built from two pseudo-elements so it hugs the key. Keys type into the field, arrow keys move between them and only one key sits in the tab order.

The main color sets the caret and focus ring, the second the color of the balloon. Change the rows to match another layout, or reuse the balloon on number pads, PIN entry screens and on-screen keyboards for kiosks.

## Code

### HTML

```html
<div class="uvq08-kbd"><div class="fd"><span class="tx" aria-live="polite">Hello</span><i class="cr" aria-hidden="true"></i></div><div class="kb" role="group" aria-label="Keyboard"><div class="rw"><button type="button" class="k lt" data-k="Q" tabindex="0">Q</button><button type="button" class="k lt" data-k="W" tabindex="-1">W</button><button type="button" class="k lt" data-k="E" tabindex="-1">E</button><button type="button" class="k lt" data-k="R" tabindex="-1">R</button><button type="button" class="k lt" data-k="T" tabindex="-1">T</button><button type="button" class="k lt" data-k="Y" tabindex="-1">Y</button><button type="button" class="k lt" data-k="U" tabindex="-1">U</button><button type="button" class="k lt" data-k="I" tabindex="-1">I</button><button type="button" class="k lt" data-k="O" tabindex="-1">O</button><button type="button" class="k lt" data-k="P" tabindex="-1">P</button></div><div class="rw"><button type="button" class="k lt" data-k="A" tabindex="-1">A</button><button type="button" class="k lt" data-k="S" tabindex="-1">S</button><button type="button" class="k lt" data-k="D" tabindex="-1">D</button><button type="button" class="k lt" data-k="F" tabindex="-1">F</button><button type="button" class="k lt" data-k="G" tabindex="-1">G</button><button type="button" class="k lt" data-k="H" tabindex="-1">H</button><button type="button" class="k lt" data-k="J" tabindex="-1">J</button><button type="button" class="k lt" data-k="K" tabindex="-1">K</button><button type="button" class="k lt" data-k="L" tabindex="-1">L</button><button type="button" class="k lt pk" data-k="Ñ" tabindex="-1">Ñ</button></div><div class="rw"><button type="button" class="k lt" data-k="Z" tabindex="-1">Z</button><button type="button" class="k lt" data-k="X" tabindex="-1">X</button><button type="button" class="k lt" data-k="C" tabindex="-1">C</button><button type="button" class="k lt" data-k="V" tabindex="-1">V</button><button type="button" class="k lt" data-k="B" tabindex="-1">B</button><button type="button" class="k lt" data-k="N" tabindex="-1">N</button><button type="button" class="k lt" data-k="M" tabindex="-1">M</button><button type="button" class="k bk" data-k="⌫" aria-label="Clear" tabindex="-1">⌫</button></div><div class="rw"><button type="button" class="k sp" data-k=" " tabindex="-1">space</button></div></div></div>
```

### CSS

```css
.uvq08-kbd {
  --c1: #0a84ff;
  --c2: #8e8e93;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq08-kbd {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  display: grid;
  gap: .7em;
  padding-top: 1.2em;
}

.uvq08-kbd .fd {
  display: flex;
  align-items: center;
  min-height: 2.4em;
  padding: 0 1em;
  border-radius: 1.2em;
  font-size: .95em;
  color: #fff;
  background: #1c1c1e;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.uvq08-kbd .tx {
  white-space: pre;
}

.uvq08-kbd .cr {
  width: 2px;
  height: 1.2em;
  margin-left: 1px;
  border-radius: 1px;
  background: var(--c1);
  animation: uvq08-kbd-c 1s steps(1,end) infinite;
}

.uvq08-kbd .kb {
  display: grid;
  gap: .5em;
  padding: .6em .35em .7em;
  border-radius: .9em;
  background: #2c2c2e;
  box-shadow: 0 1.2em 2em -1.2em rgba(0,0,0,.6);
}

.uvq08-kbd .rw {
  display: flex;
  justify-content: center;
  gap: .28em;
}

.uvq08-kbd .k {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  width: 1.65em;
  height: 2.3em;
  border-radius: .35em;
  font-size: 1em;
  font-weight: 500;
  color: #fff;
  background: #6b6b70;
  box-shadow: 0 1px 0 rgba(0,0,0,.6);
  transition: background calc(0.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-kbd .bk {
  width: 2.6em;
  margin-left: .4em;
  background: #48484c;
}

.uvq08-kbd .sp {
  width: 11em;
  font-size: .8em;
  height: 2.9em;
  color: #e5e5ea;
}

.uvq08-kbd .k:active {
  background: #8e8e93;
}

.uvq08-kbd .k:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq08-kbd .lt::before,.uvq08-kbd .lt::after {
  position: absolute;
  left: 50%;
  z-index: 2;
  background: var(--c2);
  pointer-events: none;
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.15s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-kbd .lt::before {
  content: attr(data-k);
  bottom: calc(100% + .05em);
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  translate: -50% 0;
  border-radius: .3em .3em .25em .25em;
  font-size: 1.6em;
  font-weight: 400;
  box-shadow: 0 .1em .3em rgba(0,0,0,.4);
  transform: scale(.5);
}

.uvq08-kbd .lt::after {
  content: "";
  bottom: 0;
  width: 100%;
  height: calc(100% + .2em);
  translate: -50% 0;
  border-radius: 0 0 .35em .35em;
  transform: scaleY(.8);
}

.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::before,.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::after {
  opacity: 1;
  transform: none;
}

@keyframes uvq08-kbd-c {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq08-kbd,.uvq08-kbd *,.uvq08-kbd *::before,.uvq08-kbd *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq08-kbd").forEach(el => {
  const unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const ks=[...el.querySelectorAll(".k")],tx=el.querySelector(".tx"),kb=el.querySelector(".kb"),rows=[...el.querySelectorAll(".rw")].map(r=>[...r.querySelectorAll(".k")]),tm=new Map();let cur=ks.find(k=>k.tabIndex===0)||ks[0];
const type=k=>{const c=k.dataset.k;let s=tx.textContent;s=c==="⌫"?s.slice(0,-1):(s+c.toLowerCase()).slice(-22);tx.textContent=s;k.classList.add("on");clearTimeout(tm.get(k));tm.set(k,setTimeout(()=>k.classList.remove("on"),220))};
const go=k=>{if(!k)return;cur.tabIndex=-1;cur=k;k.tabIndex=0;k.focus()};
ks.forEach(k=>{k.addEventListener("click",()=>type(k));k.addEventListener("focus",()=>{cur.tabIndex=-1;cur=k;k.tabIndex=0})});
kb.addEventListener("keydown",e=>{const ri=rows.findIndex(r=>r.includes(cur)),ci=rows[ri].indexOf(cur);
if(e.key==="ArrowRight")go(rows[ri][ci+1]);else if(e.key==="ArrowLeft")go(rows[ri][ci-1]);
else if(e.key==="ArrowDown"||e.key==="ArrowUp"){const r=rows[ri+(e.key==="ArrowDown"?1:-1)];if(r)go(r[Math.round(ci/Math.max(1,rows[ri].length-1)*(r.length-1))])}
else if(e.key==="Backspace")type(el.querySelector(".bk"));
else if(/^[a-zñ]$/i.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const m=ks.find(k=>k.dataset.k===e.key.toUpperCase());if(!m)return;go(m);type(m)}
else return;e.preventDefault()});
return()=>tm.forEach(t=>clearTimeout(t))
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq08-kbd {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  display: grid;
  gap: .7em;
  padding-top: 1.2em;
}

.uvq08-kbd .fd {
  display: flex;
  align-items: center;
  min-height: 2.4em;
  padding: 0 1em;
  border-radius: 1.2em;
  font-size: .95em;
  color: #fff;
  background: #1c1c1e;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.uvq08-kbd .tx {
  white-space: pre;
}

.uvq08-kbd .cr {
  width: 2px;
  height: 1.2em;
  margin-left: 1px;
  border-radius: 1px;
  background: var(--c1);
  animation: uvq08-kbd-c 1s steps(1,end) infinite;
}

.uvq08-kbd .kb {
  display: grid;
  gap: .5em;
  padding: .6em .35em .7em;
  border-radius: .9em;
  background: #2c2c2e;
  box-shadow: 0 1.2em 2em -1.2em rgba(0,0,0,.6);
}

.uvq08-kbd .rw {
  display: flex;
  justify-content: center;
  gap: .28em;
}

.uvq08-kbd .k {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  width: 1.65em;
  height: 2.3em;
  border-radius: .35em;
  font-size: 1em;
  font-weight: 500;
  color: #fff;
  background: #6b6b70;
  box-shadow: 0 1px 0 rgba(0,0,0,.6);
  transition: background calc(0.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-kbd .bk {
  width: 2.6em;
  margin-left: .4em;
  background: #48484c;
}

.uvq08-kbd .sp {
  width: 11em;
  font-size: .8em;
  height: 2.9em;
  color: #e5e5ea;
}

.uvq08-kbd .k:active {
  background: #8e8e93;
}

.uvq08-kbd .k:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq08-kbd .lt::before,.uvq08-kbd .lt::after {
  position: absolute;
  left: 50%;
  z-index: 2;
  background: var(--c2);
  pointer-events: none;
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.15s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-kbd .lt::before {
  content: attr(data-k);
  bottom: calc(100% + .05em);
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  translate: -50% 0;
  border-radius: .3em .3em .25em .25em;
  font-size: 1.6em;
  font-weight: 400;
  box-shadow: 0 .1em .3em rgba(0,0,0,.4);
  transform: scale(.5);
}

.uvq08-kbd .lt::after {
  content: "";
  bottom: 0;
  width: 100%;
  height: calc(100% + .2em);
  translate: -50% 0;
  border-radius: 0 0 .35em .35em;
  transform: scaleY(.8);
}

.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::before,.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::after {
  opacity: 1;
  transform: none;
}

@keyframes uvq08-kbd-c {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq08-kbd,.uvq08-kbd *,.uvq08-kbd *::before,.uvq08-kbd *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const ks=[...el.querySelectorAll(".k")],tx=el.querySelector(".tx"),kb=el.querySelector(".kb"),rows=[...el.querySelectorAll(".rw")].map(r=>[...r.querySelectorAll(".k")]),tm=new Map();let cur=ks.find(k=>k.tabIndex===0)||ks[0];
const type=k=>{const c=k.dataset.k;let s=tx.textContent;s=c==="⌫"?s.slice(0,-1):(s+c.toLowerCase()).slice(-22);tx.textContent=s;k.classList.add("on");clearTimeout(tm.get(k));tm.set(k,setTimeout(()=>k.classList.remove("on"),220))};
const go=k=>{if(!k)return;cur.tabIndex=-1;cur=k;k.tabIndex=0;k.focus()};
ks.forEach(k=>{k.addEventListener("click",()=>type(k));k.addEventListener("focus",()=>{cur.tabIndex=-1;cur=k;k.tabIndex=0})});
kb.addEventListener("keydown",e=>{const ri=rows.findIndex(r=>r.includes(cur)),ci=rows[ri].indexOf(cur);
if(e.key==="ArrowRight")go(rows[ri][ci+1]);else if(e.key==="ArrowLeft")go(rows[ri][ci-1]);
else if(e.key==="ArrowDown"||e.key==="ArrowUp"){const r=rows[ri+(e.key==="ArrowDown"?1:-1)];if(r)go(r[Math.round(ci/Math.max(1,rows[ri].length-1)*(r.length-1))])}
else if(e.key==="Backspace")type(el.querySelector(".bk"));
else if(/^[a-zñ]$/i.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const m=ks.find(k=>k.dataset.k===e.key.toUpperCase());if(!m)return;go(m);type(m)}
else return;e.preventDefault()});
return()=>tm.forEach(t=>clearTimeout(t))
}

export default function TipKeyPreview() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0a84ff",
          "--c2": "#8e8e93",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-kbd"><div className="fd"><span className="tx" aria-live="polite">Hello</span><i className="cr" aria-hidden="true"></i></div><div className="kb" role="group" aria-label="Keyboard"><div className="rw"><button type="button" className="k lt" data-k="Q" tabIndex={0}>Q</button><button type="button" className="k lt" data-k="W" tabIndex={-1}>W</button><button type="button" className="k lt" data-k="E" tabIndex={-1}>E</button><button type="button" className="k lt" data-k="R" tabIndex={-1}>R</button><button type="button" className="k lt" data-k="T" tabIndex={-1}>T</button><button type="button" className="k lt" data-k="Y" tabIndex={-1}>Y</button><button type="button" className="k lt" data-k="U" tabIndex={-1}>U</button><button type="button" className="k lt" data-k="I" tabIndex={-1}>I</button><button type="button" className="k lt" data-k="O" tabIndex={-1}>O</button><button type="button" className="k lt" data-k="P" tabIndex={-1}>P</button></div><div className="rw"><button type="button" className="k lt" data-k="A" tabIndex={-1}>A</button><button type="button" className="k lt" data-k="S" tabIndex={-1}>S</button><button type="button" className="k lt" data-k="D" tabIndex={-1}>D</button><button type="button" className="k lt" data-k="F" tabIndex={-1}>F</button><button type="button" className="k lt" data-k="G" tabIndex={-1}>G</button><button type="button" className="k lt" data-k="H" tabIndex={-1}>H</button><button type="button" className="k lt" data-k="J" tabIndex={-1}>J</button><button type="button" className="k lt" data-k="K" tabIndex={-1}>K</button><button type="button" className="k lt" data-k="L" tabIndex={-1}>L</button><button type="button" className="k lt pk" data-k="Ñ" tabIndex={-1}>Ñ</button></div><div className="rw"><button type="button" className="k lt" data-k="Z" tabIndex={-1}>Z</button><button type="button" className="k lt" data-k="X" tabIndex={-1}>X</button><button type="button" className="k lt" data-k="C" tabIndex={-1}>C</button><button type="button" className="k lt" data-k="V" tabIndex={-1}>V</button><button type="button" className="k lt" data-k="B" tabIndex={-1}>B</button><button type="button" className="k lt" data-k="N" tabIndex={-1}>N</button><button type="button" className="k lt" data-k="M" tabIndex={-1}>M</button><button type="button" className="k bk" data-k="⌫" aria-label="Clear" tabIndex={-1}>⌫</button></div><div className="rw"><button type="button" className="k sp" data-k=" " tabIndex={-1}>space</button></div></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Keyboard key preview tooltip” block (Tooltips) from AIMRAN Library to my project.

## What it is
A phone keyboard where each key grows upward into a balloon with a large letter when pressed or focused.

## Chosen settings
- Main color: #0a84ff
- Secondary color: #8e8e93
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Hello"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq08-kbd {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  display: grid;
  gap: .7em;
  padding-top: 1.2em;
}

.uvq08-kbd .fd {
  display: flex;
  align-items: center;
  min-height: 2.4em;
  padding: 0 1em;
  border-radius: 1.2em;
  font-size: .95em;
  color: #fff;
  background: #1c1c1e;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.uvq08-kbd .tx {
  white-space: pre;
}

.uvq08-kbd .cr {
  width: 2px;
  height: 1.2em;
  margin-left: 1px;
  border-radius: 1px;
  background: var(--c1);
  animation: uvq08-kbd-c 1s steps(1,end) infinite;
}

.uvq08-kbd .kb {
  display: grid;
  gap: .5em;
  padding: .6em .35em .7em;
  border-radius: .9em;
  background: #2c2c2e;
  box-shadow: 0 1.2em 2em -1.2em rgba(0,0,0,.6);
}

.uvq08-kbd .rw {
  display: flex;
  justify-content: center;
  gap: .28em;
}

.uvq08-kbd .k {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  width: 1.65em;
  height: 2.3em;
  border-radius: .35em;
  font-size: 1em;
  font-weight: 500;
  color: #fff;
  background: #6b6b70;
  box-shadow: 0 1px 0 rgba(0,0,0,.6);
  transition: background calc(0.1s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-kbd .bk {
  width: 2.6em;
  margin-left: .4em;
  background: #48484c;
}

.uvq08-kbd .sp {
  width: 11em;
  font-size: .8em;
  height: 2.9em;
  color: #e5e5ea;
}

.uvq08-kbd .k:active {
  background: #8e8e93;
}

.uvq08-kbd .k:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq08-kbd .lt::before,.uvq08-kbd .lt::after {
  position: absolute;
  left: 50%;
  z-index: 2;
  background: var(--c2);
  pointer-events: none;
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.15s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-kbd .lt::before {
  content: attr(data-k);
  bottom: calc(100% + .05em);
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  translate: -50% 0;
  border-radius: .3em .3em .25em .25em;
  font-size: 1.6em;
  font-weight: 400;
  box-shadow: 0 .1em .3em rgba(0,0,0,.4);
  transform: scale(.5);
}

.uvq08-kbd .lt::after {
  content: "";
  bottom: 0;
  width: 100%;
  height: calc(100% + .2em);
  translate: -50% 0;
  border-radius: 0 0 .35em .35em;
  transform: scaleY(.8);
}

.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::before,.uvq08-kbd .lt:is(:hover,:focus-visible,.on,.pk)::after {
  opacity: 1;
  transform: none;
}

@keyframes uvq08-kbd-c {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq08-kbd,.uvq08-kbd *,.uvq08-kbd *::before,.uvq08-kbd *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const ks=[...el.querySelectorAll(".k")],tx=el.querySelector(".tx"),kb=el.querySelector(".kb"),rows=[...el.querySelectorAll(".rw")].map(r=>[...r.querySelectorAll(".k")]),tm=new Map();let cur=ks.find(k=>k.tabIndex===0)||ks[0];
const type=k=>{const c=k.dataset.k;let s=tx.textContent;s=c==="⌫"?s.slice(0,-1):(s+c.toLowerCase()).slice(-22);tx.textContent=s;k.classList.add("on");clearTimeout(tm.get(k));tm.set(k,setTimeout(()=>k.classList.remove("on"),220))};
const go=k=>{if(!k)return;cur.tabIndex=-1;cur=k;k.tabIndex=0;k.focus()};
ks.forEach(k=>{k.addEventListener("click",()=>type(k));k.addEventListener("focus",()=>{cur.tabIndex=-1;cur=k;k.tabIndex=0})});
kb.addEventListener("keydown",e=>{const ri=rows.findIndex(r=>r.includes(cur)),ci=rows[ri].indexOf(cur);
if(e.key==="ArrowRight")go(rows[ri][ci+1]);else if(e.key==="ArrowLeft")go(rows[ri][ci-1]);
else if(e.key==="ArrowDown"||e.key==="ArrowUp"){const r=rows[ri+(e.key==="ArrowDown"?1:-1)];if(r)go(r[Math.round(ci/Math.max(1,rows[ri].length-1)*(r.length-1))])}
else if(e.key==="Backspace")type(el.querySelector(".bk"));
else if(/^[a-zñ]$/i.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const m=ks.find(k=>k.dataset.k===e.key.toUpperCase());if(!m)return;go(m);type(m)}
else return;e.preventDefault()});
return()=>tm.forEach(t=>clearTimeout(t))
}

export default function TipKeyPreview() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0a84ff",
          "--c2": "#8e8e93",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-kbd"><div className="fd"><span className="tx" aria-live="polite">Hello</span><i className="cr" aria-hidden="true"></i></div><div className="kb" role="group" aria-label="Keyboard"><div className="rw"><button type="button" className="k lt" data-k="Q" tabIndex={0}>Q</button><button type="button" className="k lt" data-k="W" tabIndex={-1}>W</button><button type="button" className="k lt" data-k="E" tabIndex={-1}>E</button><button type="button" className="k lt" data-k="R" tabIndex={-1}>R</button><button type="button" className="k lt" data-k="T" tabIndex={-1}>T</button><button type="button" className="k lt" data-k="Y" tabIndex={-1}>Y</button><button type="button" className="k lt" data-k="U" tabIndex={-1}>U</button><button type="button" className="k lt" data-k="I" tabIndex={-1}>I</button><button type="button" className="k lt" data-k="O" tabIndex={-1}>O</button><button type="button" className="k lt" data-k="P" tabIndex={-1}>P</button></div><div className="rw"><button type="button" className="k lt" data-k="A" tabIndex={-1}>A</button><button type="button" className="k lt" data-k="S" tabIndex={-1}>S</button><button type="button" className="k lt" data-k="D" tabIndex={-1}>D</button><button type="button" className="k lt" data-k="F" tabIndex={-1}>F</button><button type="button" className="k lt" data-k="G" tabIndex={-1}>G</button><button type="button" className="k lt" data-k="H" tabIndex={-1}>H</button><button type="button" className="k lt" data-k="J" tabIndex={-1}>J</button><button type="button" className="k lt" data-k="K" tabIndex={-1}>K</button><button type="button" className="k lt" data-k="L" tabIndex={-1}>L</button><button type="button" className="k lt pk" data-k="Ñ" tabIndex={-1}>Ñ</button></div><div className="rw"><button type="button" className="k lt" data-k="Z" tabIndex={-1}>Z</button><button type="button" className="k lt" data-k="X" tabIndex={-1}>X</button><button type="button" className="k lt" data-k="C" tabIndex={-1}>C</button><button type="button" className="k lt" data-k="V" tabIndex={-1}>V</button><button type="button" className="k lt" data-k="B" tabIndex={-1}>B</button><button type="button" className="k lt" data-k="N" tabIndex={-1}>N</button><button type="button" className="k lt" data-k="M" tabIndex={-1}>M</button><button type="button" className="k bk" data-k="⌫" aria-label="Clear" tabIndex={-1}>⌫</button></div><div className="rw"><button type="button" className="k sp" data-k=" " tabIndex={-1}>space</button></div></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
