The iOS keyboard, before and after

The same chat screen in iOS Safari. Left: the usual full-height flex column. Right: wrapped in steady-keyboard. Replayed from frame-by-frame measurements on an iPhone (iOS 27): layout viewport 695 px, keyboard 330 px.

Before100dvh flex column

Safari pans the page to reveal the field

Aftersteady-keyboard

The shell makes room before Safari looks

What the shell does

  1. Sizes itself to the visual viewport in the first resize (+95 ms). When Safari checks at +200 ms, the field already sits above the keyboard: nothing to reveal, no pan.
  2. Moves the bar in one frame on the way up. Animating it from its old place makes Safari see it below the keyboard and pan anyway.
  3. Undoes any pan that happens anyway (scrollTo(0, 0)) instead of following it. Following it is the classic "jump, then squish".
  4. Cold first keyboard: no keyboard 120 ms after a touch focus means it's the slow one (+930 ms). Room is made early, at the last measured height.
  5. Closing: the bar glides down with the keyboard (300 ms, iOS curve).

Using it

import { useKeyboardShell, focusWithoutScroll }
  from "steady-keyboard/react";
import "steady-keyboard/shell.css";

function App() {
  useKeyboardShell({ storagePrefix: "my-app" });
  return (
    <div className="keyboard-shell">
      <header>…</header>
      <main style={{ flex: 1, overflowY: "auto" }}>…</main>
      <form data-keyboard-bar>
        <textarea onTouchEnd={focusWithoutScroll} />
      </form>
    </div>
  );
}

What Safari does (measured)

tap → focusin +95 ms visual viewport shrinks 695 → 365 +200 ms pans the page up 330 px, only if the focused field is still below the keyboard ~300 ms keyboard and pan finish first keyboard after a load: resize and pan arrive together at ~930 ms

A replay of the measured behaviour, drawn in the browser. To see the real thing, open /demo/ on an iPhone, and /demo/?fix=off for the same page without the fix. Locally: pnpm dev.