Skip to content

Commit 94223ef

Browse files
committed
Add support for parsing "Command/Ctrl" in OS::find_keycode_from_string
1 parent 9a39760 commit 94223ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/os/keyboard.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "keyboard.h"
3232

3333
#include "core/os/os.h"
34+
#include "modules/regex/regex.h"
3435

3536
struct _KeyCodeText {
3637
Key code;
@@ -435,6 +436,12 @@ Key find_keycode(const String &p_codestr) {
435436
keycode |= KeyModifierMask::META;
436437
} else if (code_part.nocasecmp_to(find_keycode_name(Key::ALT)) == 0) {
437438
keycode |= KeyModifierMask::ALT;
439+
} else if (RegEx("(?i)(?:command/ctrl)|(?:ctrl/command)").search(code_part).is_valid()) {
440+
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
441+
keycode |= KeyModifierMask::META;
442+
} else {
443+
keycode |= KeyModifierMask::CTRL;
444+
}
438445
}
439446
}
440447

0 commit comments

Comments
 (0)