Virtual Keyboard API
Lets a page control whether the on-screen keyboard resizes the page or overlays it, and show or hide 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
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 94 | 2021-09-21 | None |
| Edge | Supported | 94 | 2021-09-24 | None |
| Firefox | Not supported | Not available | Not listed | None |
| Safari | Not supported | Not available | Not listed | None |
| Safari on iPhone | Not supported | Not available | Not listed | None |
| Chrome on Android | Supported | 94 | 2021-09-21 | None |
| Samsung Internet | Supported | 17.0 | 2022-05-04 | None |
How a site asks for it
| API | navigator.virtualKeyboard.overlaysContent; show(); hide(); boundingRect; geometrychange; env(keyboard-inset-height); virtualkeyboardpolicy |
| Browser compat keys | api.VirtualKeyboardapi.Navigator.virtualKeyboard |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | While the page runs |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | Main frame only; cross-origin iframes cannot control it |
Typical flow
- Page sets overlaysContent = true
- Keyboard appears over the page
- 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
| Type | Example | Apps |
|---|---|---|
| messaging | A chat web app keeps the message box and send button above the keyboard on a phone. | WhatsApp Web, Slack |
| games | A browser game with touch buttons keeps them in view when the keyboard opens for a chat message. | None named |
| productivity | A mobile document editor keeps the toolbar just above the keyboard. | Google Docs |
| shopping | A checkout page scrolls the field you are typing in so the pay button stays reachable. | None named |
| analytics | A site notes keyboard height as a clue to device model and OS keyboard settings. | None named |
| accessibility | A 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
- Google Chrome: VirtualKeyboard API. Chrome describes it as a way for web apps to control layout around the on screen keyboard and show or hide it.
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
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 3 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 1 | Rough 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.