@@ -360,51 +360,45 @@ bool keycode_has_unicode(Key p_keycode) {
360360}
361361
362362String keycode_get_string (Key p_code) {
363- String codestr;
364- if ((p_code & KeyModifierMask::SHIFT) != Key::NONE) {
365- codestr += find_keycode_name (Key::SHIFT);
366- codestr += " +" ;
363+ Vector<String> keycode_string;
364+ if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && !(OS::get_singleton ()->has_feature (" macos" ) || OS::get_singleton ()->has_feature (" web_macos" ) || OS::get_singleton ()->has_feature (" web_ios" ))) {
365+ keycode_string.push_back (find_keycode_name (Key::CTRL));
366+ }
367+ if ((p_code & KeyModifierMask::CTRL) != Key::NONE) {
368+ keycode_string.push_back (find_keycode_name (Key::CTRL));
367369 }
368370 if ((p_code & KeyModifierMask::ALT) != Key::NONE) {
369- codestr += find_keycode_name (Key::ALT);
370- codestr += " +" ;
371+ keycode_string.push_back (find_keycode_name (Key::ALT));
371372 }
372- if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE) {
373- if (OS::get_singleton ()->has_feature (" macos" ) || OS::get_singleton ()->has_feature (" web_macos" ) || OS::get_singleton ()->has_feature (" web_ios" )) {
374- codestr += find_keycode_name (Key::META);
375- } else {
376- codestr += find_keycode_name (Key::CTRL);
377- }
378- codestr += " +" ;
373+ if ((p_code & KeyModifierMask::SHIFT) != Key::NONE) {
374+ keycode_string.push_back (find_keycode_name (Key::SHIFT));
379375 }
380- if ((p_code & KeyModifierMask::CTRL) != Key::NONE) {
381- codestr += find_keycode_name (Key::CTRL);
382- codestr += " +" ;
376+ if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && (OS::get_singleton ()->has_feature (" macos" ) || OS::get_singleton ()->has_feature (" web_macos" ) || OS::get_singleton ()->has_feature (" web_ios" ))) {
377+ keycode_string.push_back (find_keycode_name (Key::META));
383378 }
384379 if ((p_code & KeyModifierMask::META) != Key::NONE) {
385- codestr += find_keycode_name (Key::META);
386- codestr += " +" ;
380+ keycode_string.push_back (find_keycode_name (Key::META));
387381 }
388382
389383 p_code &= KeyModifierMask::CODE_MASK;
390384 if ((char32_t )p_code == 0 ) {
391385 // The key was just a modifier without any code.
392- return codestr ;
386+ return String ( " + " ). join (keycode_string) ;
393387 }
394388
389+ // The key is a named keycode.
395390 const _KeyCodeText *kct = &_keycodes[0 ];
396-
397391 while (kct->text ) {
398392 if (kct->code == p_code) {
399- codestr += kct->text ;
400- return codestr ;
393+ keycode_string. push_back ( kct->text ) ;
394+ return String ( " + " ). join (keycode_string) ;
401395 }
402396 kct++;
403397 }
404398
405- codestr += String::chr (( char32_t )p_code);
406-
407- return codestr ;
399+ // The key is a single character.
400+ keycode_string. push_back ( String::chr (( char32_t )p_code));
401+ return String ( " + " ). join (keycode_string) ;
408402}
409403
410404Key find_keycode (const String &p_codestr) {
0 commit comments