Skip to Content
Platform.Ontology

Virtual Keyboard API

Lets a page control whether the on-screen keyboard resizes the page or overlays it, and show or hide it.

Works without askingTyping and clipboardMobile inputWeb browsersWhile you use it

In one line

Can control how the on screen keyboard moves the page, and show or hide it

Lets a page control whether the on-screen keyboard resizes the page or overlays it, and show or hide it.

A web app can take over keyboard layout handling and learn the keyboard rectangle. Keyboard height hints at device type and which keyboard (emoji, numeric) is open.

What it can and can't do

What the user does: You tap into a text box on a phone or tablet

It can

  • Choose whether the keyboard pushes the page up or covers it
  • Learn the size and place of the keyboard
  • Show or hide the on screen keyboard from a tap

It cannot

  • See what you type on the on screen keyboard
  • Show the keyboard without a tap on the page
  • Work in Firefox or Safari

How it differs between platforms: Chrome, Edge and Samsung Internet support it. Firefox and Safari do not.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported942021-09-21None
EdgeSupported942021-09-24None
FirefoxNot supportedNot availableNot listedNone
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidSupported942021-09-21None
Samsung InternetSupported17.02022-05-04None

How a site asks for it

APInavigator.virtualKeyboard.overlaysContent; show(); hide(); boundingRect; geometrychange; env(keyboard-inset-height); virtualkeyboardpolicy
Browser compat keysapi.VirtualKeyboard
api.Navigator.virtualKeyboard
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)No
Needs a user gestureNo
Activationnone
How long it lastsWhile the page runs
How to take it backNothing to revoke (no permission is stored)
Inside an iframeMain frame only; cross-origin iframes cannot control it

Typical flow

  1. Page sets overlaysContent = true
  2. Keyboard appears over the page
  3. geometrychange reports the rectangle

Data you get

Shape: none

No individual data fields. The signal is the access itself.

Technical limits

  • Chromium on Android and ChromeOS only (Chrome 94); no Firefox or Safari
  • show() and hide() need a focused editable element and (for show) a recent user action
  • CSS env() variables keyboard-inset-top, -left, -bottom, -right, -width, -height
  • Cannot read keystrokes or which keyboard app is installed; only the rectangle

The story

What it is

A web app can control whether your on screen keyboard pushes the page up or covers it.

For you

You tap a text box and the keyboard slides up. The page may shrink neatly so your message box stays visible, or the keyboard may overlay a game controller. You may not realize the page can also learn how tall the keyboard is.

For makers

Chat, game and editing apps want to keep the box you are typing in on screen. Makers use the keyboard size to place buttons well. The height also hints at the device and keyboard type.

Where you see it

TypeExampleApps
messagingA chat web app keeps the message box and send button above the keyboard on a phone.WhatsApp Web, Slack
gamesA browser game with touch buttons keeps them in view when the keyboard opens for a chat message.None named
productivityA mobile document editor keeps the toolbar just above the keyboard.Google Docs
shoppingA checkout page scrolls the field you are typing in so the pay button stays reachable.None named
analyticsA site notes keyboard height as a clue to device model and OS keyboard settings.None named
accessibilityA web app lets people using an on screen keyboard with larger text keep fields visible.None named

Risks

  • Keyboard height hints at device
  • Little else

What the platform says

Good uses and abuse

Legitimate uses

  • Chat composers and bottom sheets
  • Games with custom on-screen controls

Known abuse

  • Device and keyboard type hints

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits1Rough identifying entropy, when known

History

  • 2021-09, Chrome 94: VirtualKeyboard API ships on Android
  • 2022-11, Chrome 108: interactive-widget viewport meta option ships

Sources

How well checked: Based on official documentation.

On this page