KeyboardLayoutMap:keys() 方法
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
KeyboardLayoutMap
接口的 keys()
方法返回一个新的迭代器对象,该对象包含 KeyboardLayoutMap
对象中每个索引的键。
该方法与 Map.prototype.keys()
相似。
语法
js
keys()
返回值
一个新的迭代器对象。
示例
以下示例迭代英文 QWERTY 键盘上的每个键盘代码。
js
navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
for (const code of keyboardLayoutMap.keys()) {
console.log(`${code} 键盘代码`);
}
});
规范
Specification |
---|
ECMAScript® 2025 Language Specification # sec-map.prototype.keys |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
keys |
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.