Limited availability
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 geometrychange
event of the VirtualKeyboard
interface fires when the on-screen virtual keyboard is toggled between shown and hidden states.
The geometrychange
event is useful to detect when the virtual keyboard appears and disappears, so you can adjust the layout as appropriate. This is necessary when using the Virtual Keyboard API to disable the browser's default automatic resizing of the viewport when the virtual keyboard is shown and hidden.
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener("geometrychange", (event) => { })
ongeometrychange = (event) => { }
Event type
A generic Event
.
The following code snippet uses the geometrychange
event to detect when the virtual keyboard geometry changes, and then accesses the boundingRect
property to query the size and position of the virtual keyboard:
if ("virtualKeyboard" in navigator) {
navigator.virtualKeyboard.overlaysContent = true;
navigator.virtualKeyboard.addEventListener("geometrychange", (event) => {
const { x, y, width, height } = event.target.boundingRect;
});
}
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4