Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-CN]: add translation for KeyboardLayoutMap.entries() #24187

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions files/zh-cn/web/api/keyboardlayoutmap/entries/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: KeyboardLayoutMap:entries() 方法
slug: Web/API/KeyboardLayoutMap/entries
l10n:
sourceCommit: 33d8f835c12481741d0008c1ded4b91634e60d1c
---

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

{{domxref("KeyboardLayoutMap")}} 接口的 **`entries()`** 方法返回一个新的[迭代器](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Iterator)对象,该对象包含键/值对,顺序与 {{jsxref("Statements/for...in", "for...in")}} 循环提供的顺序相同(不同之处在于 `for-in` 循环也会枚举原型链中的属性)。

该方法与 {{jsxref("Map.prototype.entries()")}} 相似。

## 值

一个新的[迭代器](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Iterator)对象。

## 示例

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

```js
navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
for (const [code, key] of keyboardLayoutMap.entries()) {
console.log(`键盘代码 ${code} 代表键 ${key} key`);
skyclouds2001 marked this conversation as resolved.
Show resolved Hide resolved
}
});
```

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{jsxref("Map.prototype.entries()")}}