The HTML virtualkeyboardpolicy attribute
The HTML virtualkeyboardpolicy attribute controls whether the on-screen keyboard appears automatically when a contenteditable element is focused. Values are auto and manual. It is a global attribute from the VirtualKeyboard API, currently in Chromium-based browsers.
Overview
On editable elements, focusing usually pops up the on-screen keyboard automatically. The virtualkeyboardpolicy attribute lets you take control: auto keeps the default behavior, while manual stops the automatic keyboard so you can show or hide it yourself through the VirtualKeyboard API.
This is useful for custom editing surfaces (drawing apps, code editors, games) where the default keyboard would get in the way. Support is currently limited to Chromium-based browsers.
Values
| Value |
|---|
| auto | manual |
Example
<div contenteditable="true" virtualkeyboardpolicy="manual" style="border:1px solid #cbd5e1; padding:10px; border-radius:8px;">Editable region with manual virtual-keyboard control.</div>
Best practices
- Use inputmode to bring up the right on-screen keyboard (numeric, email, and so on).
- Set autocapitalize appropriately — off for names and codes, sentences for prose.
- These are hints; do not rely on them for validation.
- Test on real mobile devices, where most of these take effect.