From bc0f9122791ca008fcacec8bafea666701fc43b2 Mon Sep 17 00:00:00 2001 From: PP Date: Thu, 6 Jan 2022 23:05:56 +0800 Subject: [PATCH] fix keyboard event listening on mobile (#9935) * fix keyboard event listening on mobile * update deprecation info --- cocos/core/platform/macro.ts | 2 +- cocos/input/types/key-code.ts | 6 ++++++ pal/system-info/native/system-info.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos/core/platform/macro.ts b/cocos/core/platform/macro.ts index 53e07345ab..28a752e3b5 100644 --- a/cocos/core/platform/macro.ts +++ b/cocos/core/platform/macro.ts @@ -47,7 +47,7 @@ const KEY = { * @en The back key on mobile phone * @zh 移动端返回键 * @readonly - * @deprecated since v3.3 + * @deprecated since v3.3, please use KeyCode.MOBILE_BACK instead. */ back: 6, /** diff --git a/cocos/input/types/key-code.ts b/cocos/input/types/key-code.ts index 3f91766a13..e7edf595ae 100644 --- a/cocos/input/types/key-code.ts +++ b/cocos/input/types/key-code.ts @@ -9,6 +9,12 @@ export enum KeyCode { */ NONE = 0, + /** + * @en The back key on mobile phone + * @zh 移动端返回键 + */ + MOBILE_BACK = 6, + /** * @en The backspace key * @zh 退格键 diff --git a/pal/system-info/native/system-info.ts b/pal/system-info/native/system-info.ts index 6a6e8a3158..6a90b97c4c 100644 --- a/pal/system-info/native/system-info.ts +++ b/pal/system-info/native/system-info.ts @@ -83,7 +83,7 @@ class SystemInfo extends EventTarget { [Feature.SAFE_AREA]: this.isMobile, [Feature.INPUT_TOUCH]: this.isMobile, - [Feature.EVENT_KEYBOARD]: !this.isMobile, + [Feature.EVENT_KEYBOARD]: true, [Feature.EVENT_MOUSE]: !this.isMobile, [Feature.EVENT_TOUCH]: true, [Feature.EVENT_ACCELEROMETER]: this.isMobile,