Skip to content

VirtualKeyboard API #1016

@leeyucha

Description

@leeyucha

Description

The VirtualKeyboard API gives web apps fine-grained control when the on-screen keyboard appears, without relying on UA viewport resizing heuristics. It exposes:

navigator.virtualKeyboard.overlaysContent to opt out of automatic viewport adjustments,

geometrychange events plus boundingRect for keyboard geometry,

CSS env variables like env(keyboard-inset-height) to adapt layout purely with CSS.

This is critical for chat/messaging UIs, editors, and PWAs where input bars, FABs, or sticky footers are routinely occluded or cause scroll-jank. Aligning behavior across engines will remove a long-standing mobile web pain point and reduce site-specific workarounds. See MDN and Chrome docs for conceptual overview and examples.
MDN Web Docs
Chrome for Developers

Why now? Many complex apps (chat, editors, spreadsheets) still ship UA-specific hacks to avoid occlusion when the virtual keyboard appears. Interop on this API (events + CSS env vars + opt-out switch) would significantly reduce breakage and improve user experience across Android, iOS/iPadOS, ChromeOS, and desktop touch devices. (See references above.)

Specification

https://www.w3.org/TR/virtual-keyboard/

web-feature

https://web-platform-dx.github.io/web-features-explorer/features/virtual-keyboard/

Test Links

WPT live sample: virtual-keyboard/virtual-keyboard-type.https.html (checks navigator.virtualKeyboard type) — https://wpt.live/virtual-keyboard/virtual-keyboard-type.https.html
wpt.live

WPT directory (VirtualKeyboard API & policy tests) — reference: https://chromium.googlesource.com/.../wpt/+/refs/tags/epochs/daily/2024-06-09_01H/virtual-keyboard/
(contains tentative tests run with --enable-features=VirtualKeyboard)

Additional Signals

Shipping status (Chromium): Available since Chromium 94 on desktop & mobile (feature detection via navigator.virtualKeyboard).
Chrome for Developers

Mozilla standards-position: “Virtual Keyboard Control” discussion (tracking issue).
GitHub

WebKit: Request for position thread (2021) and WebKit bug tracking “Implement the VirtualKeyboard API”.
lists.webkit.org
WebKit Bugzilla

Spec maturity: W3C Web Editing WG Working Draft.
W3C

Problem background / developer pain points: MDN overview; in-depth article on fixing content occlusion.
MDN Web Docs
Ishadeed

Related work (complementary): interactive-widget viewport keyword (helps with resize policy; does not expose geometry).
Markup from hell - HTMHell

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions