GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — VirtualKeyboard - Web APIs | MDN

VirtualKeyboard

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Want more browser support for this feature? Tell us why.

  • See full compatibility
  • Learn more

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The VirtualKeyboard interface of the VirtualKeyboard API is useful on devices that have on-screen virtual keyboards, such as tablets, mobile phones, or other devices where a hardware keyboard may not be available.

The VirtualKeyboard interface makes it possible to opt out of the automatic way browsers handle on-screen virtual keyboards by reducing the height of the viewport to make room for the virtual keyboard. You can prevent the browser from changing the size of the viewport, detect the position and size of the virtual keyboard — adapting the layout of your web page as a follow-up — and programmatically show or hide the virtual keyboard.

You access the VirtualKeyboard interface by using navigator.virtualKeyboard.

Instance properties

The VirtualKeyboard interface inherits properties from its parent, EventTarget.

VirtualKeyboard.boundingRect Read only

A DOMRect that describes the geometry of the virtual keyboard.

VirtualKeyboard.overlaysContent

A Boolean that defines whether the browser should stop handling the on-screen virtual keyboard.

Instance methods

The VirtualKeyboard interface inherits methods from its parent, EventTarget.

VirtualKeyboard.show()

Show the virtual keyboard.

VirtualKeyboard.hide()

Hide the virtual keyboard.

Events

geometrychange

Fires when the geometry of the on-screen virtual keyboard changes, which happens when the virtual keyboard appears or disappears.

Example

The following example demonstrates how to opt out of the automatic virtual keyboard behavior, and detect the geometry of the virtual keyboard in the web page:

js
if ("virtualKeyboard" in navigator) {
  navigator.virtualKeyboard.overlaysContent = true;

  navigator.virtualKeyboard.addEventListener("geometrychange", (event) => {
    const { x, y, width, height } = event.target.boundingRect;
  });
}

Specifications

Specification
VirtualKeyboard API
# the-virtualkeyboard-interface

Browser compatibility

See also

  • The VirtualKeyboard API
  • Full control with the VirtualKeyboard API

Help improve MDN

Learn how to contribute

This page was last modified on Oct 30, 2023 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.