Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions cocos/input/types/key-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,18 @@ export enum KeyCode {
*/
KEY_Z = 90,

/**
* @en The left meta key (CMD on macOS, Windows key on Windows)
* @zh 左 Meta 键(macOS 上的 CMD 键,Windows 上的 Windows 键)
*/
META_LEFT = 91,

/**
* @en The right meta key (CMD on macOS, Windows key on Windows)
* @zh 右 Meta 键(macOS 上的 CMD 键,Windows 上的 Windows 键)
*/
META_RIGHT = 93,

/**
* @en The numeric keypad 0
* @zh 数字键盘 0
Expand Down
2 changes: 2 additions & 0 deletions pal/input/keycodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const code2KeyCode: Record<string, KeyCode> = {
ShiftRight: KeyCode.SHIFT_RIGHT,
ControlRight: KeyCode.CTRL_RIGHT,
AltRight: KeyCode.ALT_RIGHT,
MetaLeft: KeyCode.META_LEFT,
MetaRight: KeyCode.META_RIGHT,
Pause: KeyCode.PAUSE,
CapsLock: KeyCode.CAPS_LOCK,
Escape: KeyCode.ESCAPE,
Expand Down
2 changes: 2 additions & 0 deletions pal/input/native/keyboard-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
20016: KeyCode.SHIFT_RIGHT,
20017: KeyCode.CTRL_RIGHT,
20018: KeyCode.ALT_RIGHT,
91: KeyCode.META_LEFT,
93: KeyCode.META_RIGHT,
};

function getKeyCode (event: jsb.KeyboardEvent): KeyCode {
Expand All @@ -52,7 +54,7 @@
if (event.code in code2KeyCode) {
return code2KeyCode[event.code];
} else {
console.error(`Can not find keyCode for code: ${event.code}`);

Check failure on line 57 in pal/input/native/keyboard-input.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected console statement
}
}
return nativeKeyCode2KeyCode[event.keyCode] || event.keyCode;
Expand Down
Loading