Skip to content

Commit

Permalink
[zh-CN]: add translation for KeyboardLayoutMap.has() (#24086)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Ren <[email protected]>
  • Loading branch information
skyclouds2001 and jasonren0403 authored Oct 20, 2024
1 parent b717299 commit 7fa2795
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions files/zh-cn/web/api/keyboardlayoutmap/has/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: KeyboardLayoutMap:has() 方法
slug: Web/API/KeyboardLayoutMap/has
l10n:
sourceCommit: bcb654104082a8d12d51aecfad047d7a4a26116f
---

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

{{domxref('KeyboardLayoutMap')}} 接口的 **`has()`** 方法返回一个布尔值,指示该对象是否具有指定键的元素。

[UI 事件 KeyboardEvent 代码值](https://www.w3.org/TR/uievents-code/#key-alphanumeric-writing-system)规范中可以找到有效键的列表。

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

## 语法

```js-nolint
has(key)
```

### 参数

- `key`
- : 要在映射中搜索的元素的键。

### 返回值

{{jsxref('Boolean')}} 值,表示是否找到了指定的键。

## 示例

以下示例检查与英语 QWERTY 键盘上“W”键对应的键盘代码关联的位置或布局特定的字符串是否存在。

```js
navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
console.log(keyboardLayoutMap.has("KeyW"));
});
```

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

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

0 comments on commit 7fa2795

Please sign in to comment.