Add response for the keyboard "Menu" button. (#19096)

* Add response for the keyboard "Menu" button.

* Add keycode response for the Win/Command key.

* Add keycode response for the Win/Command key.
This commit is contained in:
qiuguohua
2025-12-09 11:39:16 +08:00
committed by GitHub
parent 1b7bbb6239
commit b8d80cb9bb
3 changed files with 8 additions and 1 deletions

View File

@@ -265,7 +265,7 @@ enum class KeyCode {
DPAD_LEFT = 1000,
DPAD_DOWN = 1004,
DPAD_RIGHT = 1001,
DPAD_CENTER = 1005
DPAD_CENTER = 1005,
};
class KeyboardEvent {

View File

@@ -35,6 +35,8 @@
namespace {
std::unordered_map<int, cc::KeyCode> gKeyMap = {
{SDLK_LGUI, cc::KeyCode::META_LEFT},
{SDLK_RGUI, cc::KeyCode::META_RIGHT},
{SDLK_APPLICATION, cc::KeyCode::CONTEXT_MENU},
{SDLK_SCROLLLOCK, cc::KeyCode::SCROLLLOCK},
{SDLK_PAUSE, cc::KeyCode::PAUSE},

View File

@@ -222,6 +222,11 @@ int ohKeyCodeToCocosKeyCode(OH_NativeXComponent_KeyCode ohKeyCode) {
{KEY_NUMPAD_7, cc::KeyCode::NUMPAD_7},
{KEY_NUMPAD_8, cc::KeyCode::NUMPAD_8},
{KEY_NUMPAD_9, cc::KeyCode::NUMPAD_9},
{KEY_MENU, cc::KeyCode::CONTEXT_MENU},
{KEY_SYSRQ, cc::KeyCode::PRINT_SCREEN},
{KEY_META_LEFT, cc::KeyCode::META_LEFT},
{KEY_META_RIGHT, cc::KeyCode::META_RIGHT},
};
if (keyCodeMap.find(ohKeyCode) != keyCodeMap.end()) {
return int(keyCodeMap[ohKeyCode]);