Back to Content

KeyboardLayoutMap: keys() method

files/en-us/web/api/keyboardlayoutmap/keys/index.md

latest922 B
Original Source

{{SeeCompatTable}}{{APIRef("Keyboard API")}}

The keys() method of the {{domxref("KeyboardLayoutMap")}} interface returns a new Iterator object that contains the keys for each index in the KeyboardLayoutMap object.

The method is otherwise the same as {{jsxref("Map.prototype.keys()")}}.

Syntax

js-nolint
keys()

Parameters

None.

Return value

A new Iterator object.

Examples

The following example iterates every keyboard code on an English QWERTY keyboard.

js
navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
  for (const code of keyboardLayoutMap.keys()) {
    console.log(`${code} keyboard code`);
  }
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{jsxref("Map.prototype.keys()")}}