From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../zh-cn/web/api/gamepadbutton/pressed/index.html | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 files/zh-cn/web/api/gamepadbutton/pressed/index.html (limited to 'files/zh-cn/web/api/gamepadbutton/pressed/index.html') diff --git a/files/zh-cn/web/api/gamepadbutton/pressed/index.html b/files/zh-cn/web/api/gamepadbutton/pressed/index.html new file mode 100644 index 0000000000..9126b26ddb --- /dev/null +++ b/files/zh-cn/web/api/gamepadbutton/pressed/index.html @@ -0,0 +1,52 @@ +--- +title: GamepadButton.pressed +slug: Web/API/GamepadButton/pressed +translation_of: Web/API/GamepadButton/pressed +--- +

{{APIRef("Gamepad API")}}

+ +

{{domxref("GamepadButton")}}接口下的 GamepadButton.pressed 属性返回一个表示按钮当然是被按下了 (true) 还是没有被按下 (false) 的布尔值。

+ +

语法

+ +
var isPressed = navigator.getGamepads()[0].pressed;
+
+ +

示例

+ +
var gp = navigator.getGamepads()[0]; // 获取第一个控制器对象
+
+if(gp.buttons[0].pressed == true) {
+  // 响应按钮按下
+}
+ +

+ +

一个 {{domxref("boolean")}} (布尔值)。

+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName("Gamepad", "#widl-GamepadButton-pressed", "GamepadButton.pressed")}}{{Spec2("Gamepad")}}Initial definition
+ +

浏览器兼容性

+ +

{{Compat("api.GamepadButton.pressed")}}

+ +

另请参阅

+ + -- cgit v1.2.3-54-g00ecf