A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/zh-CN/docs/Web/API/KeyboardLayoutMap/has below:

KeyboardLayoutMap:has() 方法 - Web API

KeyboardLayoutMap:has() 方法

Limited availability

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

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

在 UI 事件 KeyboardEvent 代码值规范中可以找到有效键的列表。

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

语法 参数
key

要在映射中搜索的元素的键。

返回值

Boolean 值,表示是否找到了指定的键。

示例

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

navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
  console.log(keyboardLayoutMap.has("KeyW"));
});
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4