MDN Web Docs

Instance properties

KeyboardLayoutMap.size Read only

Returns the number of elements in the KeyboardLayoutMap object.

Instance methods

KeyboardLayoutMap[Symbol.iterator]()

Returns a new Iterator object that contains the key/value pairs.

KeyboardLayoutMap.entries()

Returns a new Iterator object that contains the key/value pairs.

KeyboardLayoutMap.forEach()

Executes a provided function once for each element of KeyboardLayoutMap.

KeyboardLayoutMap.get()

Returns the element with the given key from the KeyboardLayoutMap object.

KeyboardLayoutMap.has()

Returns a boolean indicating whether the KeyboardLayoutMap object has an element with the specified key.

KeyboardLayoutMap.keys()

Returns a new Iterator object that contains the keys for each index in the KeyboardLayoutMap object.

KeyboardLayoutMap.values()

Returns a new Iterator object that contains the values for each index in the KeyboardLayoutMap object.

Examples

The following example demonstrates how to get the location- or layout-specific string associated with the keyboard code that corresponds to the 'W' key on an English QWERTY keyboard.

js

navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
  const upKey = keyboardLayoutMap.get("KeyW");
  window.alert(`Press ${upKey} to move up.`);
});

Specifications

Specification
Keyboard Map
# keyboardlayoutmap

Browser compatibility

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗