References

Beginner-friendly references for web development, with live, editable examples.

The HTML virtualkeyboardpolicy attribute

Global attribute Works on every element Updated
Quick answer

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

Live 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.

Frequently asked questions

What does the virtualkeyboardpolicy attribute do?
Controls whether the on-screen keyboard appears automatically for a contenteditable element.
Are these attributes guaranteed to work?
No. They are hints that browsers and on-screen keyboards may honor or ignore, especially on desktop.
Which elements do they apply to?
They are global attributes, but they mainly affect editable and form fields.
Is virtualkeyboardpolicy a global attribute?
Yes — it is a global attribute, so it can be set on any HTML element (it is a global attribute), most usefully on editable and form fields.