KeyboardLayoutMap:values() 方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

KeyboardLayoutMap 接口的 values() 方法返回一个新的迭代器对象,该对象包含 KeyboardLayoutMap 对象中每个索引的值。

该方法与 Map.prototype.values() 相似。

语法

js
values()

返回值

一个新的迭代器对象。

示例

以下示例迭代英文 QWERTY 键盘上每个位置或布局特定的字符串。

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

规范

Specification
ECMAScript® 2025 Language Specification
# sec-map.prototype.values

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
values
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

参见