Favorites

HTML virtualkeyboardpolicy Global Attribute

virtualkeyboardpolicy
HTML Global AttributeThis global attribute is supported in some modern browsers, but not all.
Updated 22nd November 2026

The virtualkeyboardpolicy attribute sets whether the on-screen keyboard opens automatically when an editable element is focused (auto) or only from script (manual).

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

Description

The virtualkeyboardpolicy global attribute controls whether the on-screen virtual keyboard opens automatically when an editable element (an <input>, a <textarea> or an element with contenteditable) receives focus.

With auto (or an empty value), which is the default, the browser shows the keyboard when the element is focused or tapped. With manual, focusing the element does not show the keyboard; the page decides when to show and hide it with the VirtualKeyboard API, navigator.virtualKeyboard.show() and hide(). This is useful for editors or games that want to show their own controls first, or to open the keyboard only on a double tap.

<div contenteditable virtualkeyboardpolicy="manual" id="editor"></div>
<script>
  editor.addEventListener("dblclick", () => navigator.virtualKeyboard.show());
</script>

The attribute is supported in Chromium-based browsers and has no effect on devices without a virtual keyboard.

Syntax

<element virtualkeyboardpolicy="auto | manual">

Values

  • autoThe browser shows the virtual keyboard automatically when the element is focused or tapped. This is the default, and an empty value has the same meaning.
  • manualThe keyboard is not shown automatically; use navigator.virtualKeyboard.show() and hide().

Example

<p>On a touch device, tap the first field to get the keyboard. The second field only opens the keyboard when you double-tap it.</p>
<div contenteditable style="border: 1px solid; padding: 10px;">Keyboard opens on focus</div>
<br>
<div contenteditable virtualkeyboardpolicy="manual" id="editor" style="border: 1px solid; padding: 10px;">Double-tap to open the keyboard</div>
<script>
document.getElementById("editor").addEventListener("dblclick", function () {
if ("virtualKeyboard" in navigator) navigator.virtualKeyboard.show();
});
</script>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML virtualkeyboardpolicy global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute is supported in some modern browsers, but not all.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee