KeyboardLayoutMap:entries() 方法
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
KeyboardLayoutMap
接口的 entries()
方法返回一个新的迭代器对象,该对象包含键/值对,顺序与 for...in
循环提供的顺序相同(不同之处在于 for-in
循环也会枚举原型链中的属性)。
该方法与 Map.prototype.entries()
相似。
语法
js
entries()
返回值
一个新的迭代器对象。
示例
以下示例迭代英文 QWERTY 键盘上每个位置或布局特定的字符串及其关联的键盘代码。
js
navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
for (const [code, key] of keyboardLayoutMap.entries()) {
console.log(`键盘代码 ${code} 代表键 ${key}`);
}
});
规范
Specification |
---|
ECMAScript® 2025 Language Specification # sec-map.prototype.entries |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
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.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.