unoplatform/uno · warning · Error
Keyboard lock is not supported by this browser.
Error message
Keyboard lock is not supported by this browser.
What it means
Thrown by BrowserInputHelper.lockKeys when the browser does not support the Keyboard Lock API (navigator.keyboard.lock). The isKeyboardLockSupported() guard checks for the presence of navigator.keyboard with both lock and unlock methods. Firefox and Safari do not implement this API; only Chromium-based browsers (Chrome, Edge, Opera) do.
Source
Thrown at src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserInputHelper.ts:12
namespace Uno.UI.Runtime.Skia {
export class BrowserInputHelper {
// Read by BrowserPointerInputSource.onPointerEventReceived
public static isBrowserZoomEnabled: boolean = true;
public static setBrowserZoomEnabled(enabled: boolean): void {
BrowserInputHelper.isBrowserZoomEnabled = enabled;
}
public static async lockKeys(keyCodes: string[]): Promise<void> {
if (!BrowserInputHelper.isKeyboardLockSupported()) {
throw new Error("Keyboard lock is not supported by this browser.");
}
const kb = (navigator as any).keyboard;
await kb.lock(
keyCodes.length > 0 ? keyCodes : undefined
);
}
public static isKeyboardLockSupported(): boolean {
const kb = (navigator as any).keyboard;
return !!kb && typeof kb.lock === "function" && typeof kb.unlock === "function";
}
public static unlockKeys(): void {
(navigator as any).keyboard?.unlock();
}
}
}View on GitHub (pinned to 0418340488)
Solutions
- Check BrowserInputHelper.isKeyboardLockSupported() (or navigator.keyboard availability) before calling lockKeys and fall back gracefully.
- Ensure the app is served over HTTPS or localhost — Keyboard Lock is a secure-context-only API.
- Inform the user that keyboard lock is Chromium-only and provide a non-locking alternative.
Example fix
// before
await BrowserInputHelper.lockKeys(keyCodes);
// after
if (BrowserInputHelper.isKeyboardLockSupported()) {
await BrowserInputHelper.lockKeys(keyCodes);
} else {
console.warn('Keyboard lock not available in this browser.');
} Defensive patterns
Strategy: validation
Validate before calling
if (!BrowserInputHelper.isKeyboardLockSupported()) {
// Skip keyboard lock — browser does not support it
return;
}
await BrowserInputHelper.lockKeys(keyCodes); Type guard
// Feature-detect the Keyboard Lock API
function supportsKeyboardLock(): boolean {
const kb = (navigator as any).keyboard;
return !!kb && typeof kb.lock === 'function' && typeof kb.unlock === 'function';
} Try / catch
try {
await BrowserInputHelper.lockKeys(keyCodes);
} catch (e) {
if (e.message === 'Keyboard lock is not supported by this browser.') {
// Graceful degradation — proceed without key lock
} else { throw e; }
} Prevention
- Always call isKeyboardLockSupported() before lockKeys.
- Serve the WASM app over HTTPS or localhost (secure context required).
- Document that keyboard lock is Chromium-only in your app's requirements.
When it happens
Trigger: C# calls the keyboard-lock interop which calls BrowserInputHelper.lockKeys on a non-Chromium browser, or on a Chromium browser where the feature flag is disabled. Also fails if the document is not served in a secure context (Keyboard Lock requires HTTPS or localhost).
Common situations: Running the WASM app in Firefox or Safari, running over plain HTTP (not localhost), or on an older Chromium version predating Keyboard Lock support.
Related errors
- retrieveFiles failed to find pending drag and drop data for
- BrowserHtmlElement: Element with id '${id}' not found.
- Function ${funcName} returned an unsupported type: ${typeof
- A DragDropExtension has already been enabled
- The current DragDropExtension does not match the provided ar
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/3fce0758a68a7221.
Report an issue: GitHub.