web api instance method
Keyboard: getLayoutMap() method
Limited availabilitySecure context
The getLayoutMap() method of the
Keyboard interface returns a Promise that resolves with
an instance of KeyboardLayoutMap which is a map-like object with
functions for retrieving the strings associated with specific physical keys.
Syntax
getLayoutMap()
Parameters
None.
Return value
A Promise that resolves with an instance of
KeyboardLayoutMap.
Exceptions
SecurityErrorDOMException- : Thrown if the call is blocked by a permission policy.
Examples
The following example demonstrates how to get the location- or layout-specific string associated with the key that corresponds to the ‘W’ key on an English QWERTY keyboard.
const keyboard = navigator.keyboard;
keyboard.getLayoutMap().then((keyboardLayoutMap) => {
const upKey = keyboardLayoutMap.get("KeyW");
window.alert(`Press ${upKey} to move up.`);
});
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.