mirror of
https://github.com/cocos/cocos-engine.git
synced 2026-09-03 06:15:06 +08:00
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:
@@ -265,7 +265,7 @@ enum class KeyCode {
|
||||
DPAD_LEFT = 1000,
|
||||
DPAD_DOWN = 1004,
|
||||
DPAD_RIGHT = 1001,
|
||||
DPAD_CENTER = 1005
|
||||
DPAD_CENTER = 1005,
|
||||
};
|
||||
|
||||
class KeyboardEvent {
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user