Back to Content

VirtualKeyboard: boundingRect property

files/en-us/web/api/virtualkeyboard/boundingrect/index.md

latest1.2 KB
Original Source

{{APIRef("VirtualKeyboard API")}}{{SeeCompatTable}}{{securecontext_header}}

The boundingRect property of the {{domxref("VirtualKeyboard")}} interface contains a {{domxref("DOMRect")}} indicating the position and size of the on-screen virtual keyboard that overlays the web page.

The on-screen virtual keyboard will overlay the viewport when the {{domxref("VirtualKeyboard_API", "Virtual Keyboard API", "", "nocode")}} is used to prevent the browser from resizing the viewport automatically. This is done by setting the {{domxref("VirtualKeyboard.overlaysContent", "overlaysContent")}} property to true.

Value

A {{domxref("DOMRect")}} which indicates the position and size of the virtual keyboard in the viewport.

The x, y, width, and height coordinates of the rectangle are useful to reposition content in the webpage that needs to be visible even when the virtual keyboard is displayed.

js
const { x, y, width, height } = navigator.virtualKeyboard.boundingRect;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also