Example 1 — Feature Detection
Check whether the VirtualKeyboard API is exposed before calling methods.
if ("virtualKeyboard" in navigator) {
console.log("VirtualKeyboard available");
} else {
console.log("VirtualKeyboard not supported");
}
console.log("secure:", window.isSecureContext); How It Works
- Ask the browser. The
inoperator checks for the property. - Gate your code. Only touch
overlaysContent/ events when present. - Check HTTPS. MDN requires a secure context in supporting browsers.
- Expect gaps. Limited availability means Firefox and Safari omit the API.

