key_equivalents.rs

   1use collections::HashMap;
   2
   3// On some keyboards (e.g. German QWERTZ) it is not possible to type the full ASCII range
   4// without using option. This means that some of our built in keyboard shortcuts do not work
   5// for those users.
   6//
   7// The way macOS solves this problem is to move shortcuts around so that they are all reachable,
   8// even if the mnemoic changes. https://developer.apple.com/documentation/swiftui/keyboardshortcut/localization-swift.struct
   9//
  10// For example, cmd-> is the "switch window" shortcut because the > key is right above tab.
  11// To ensure this doesn't cause problems for shortcuts defined for a QWERTY layout, apple moves
  12// any shortcuts defined as cmd-> to cmd-:. Coincidentally this s also the same keyboard position
  13// as cmd-> on a QWERTY layout.
  14//
  15// Another example is cmd-[ and cmd-], as they cannot be typed without option, those keys are remapped to cmd-ö
  16// and cmd-ä. These shortcuts are not in the same position as a QWERTY keyboard, because on a QWERTZ keyboard
  17// the + key is in the way; and shortcuts bound to cmd-+ are still typed as cmd-+ on either keyboard (though the
  18// specific key moves)
  19//
  20// As far as I can tell, there's no way to query the mappings Apple uses except by rendering a menu with every
  21// possible key combination, and inspecting the UI to see what it rendered. So that's what we did...
  22//
  23// These mappings were generated by running https://github.com/ConradIrwin/keyboard-inspector, tidying up the
  24// output to remove languages with no mappings and other oddities, and converting it to a less verbose representation with:
  25//  jq -s 'map(to_entries | map({key: .key, value: [(.value | to_entries | map(.key) | join("")), (.value | to_entries | map(.value) | join(""))]}) | from_entries) | add'
  26// From there I used multi-cursor to produce this match statement.
  27#[cfg(target_os = "macos")]
  28pub fn get_key_equivalents(layout: &str) -> Option<HashMap<char, char>> {
  29    let mappings: &[(char, char)] = match layout {
  30        "com.apple.keylayout.ABC-AZERTY" => &[
  31            ('!', '1'),
  32            ('"', '%'),
  33            ('#', '3'),
  34            ('$', '4'),
  35            ('%', '5'),
  36            ('&', '7'),
  37            ('(', '9'),
  38            (')', '0'),
  39            ('*', '8'),
  40            ('.', ';'),
  41            ('/', ':'),
  42            ('0', 'à'),
  43            ('1', '&'),
  44            ('2', 'é'),
  45            ('3', '"'),
  46            ('4', '\''),
  47            ('5', '('),
  48            ('6', '§'),
  49            ('7', 'è'),
  50            ('8', '!'),
  51            ('9', 'ç'),
  52            (':', '°'),
  53            (';', ')'),
  54            ('<', '.'),
  55            ('>', '/'),
  56            ('@', '2'),
  57            ('[', '^'),
  58            ('\'', 'ù'),
  59            ('\\', '`'),
  60            (']', '$'),
  61            ('^', '6'),
  62            ('`', '<'),
  63            ('{', '¨'),
  64            ('|', '£'),
  65            ('}', '*'),
  66            ('~', '>'),
  67        ],
  68        "com.apple.keylayout.ABC-QWERTZ" => &[
  69            ('"', '`'),
  70            ('#', '§'),
  71            ('&', '/'),
  72            ('(', ')'),
  73            (')', '='),
  74            ('*', '('),
  75            ('/', 'ß'),
  76            (':', 'Ü'),
  77            (';', 'ü'),
  78            ('<', ';'),
  79            ('=', '*'),
  80            ('>', ':'),
  81            ('@', '"'),
  82            ('[', 'ö'),
  83            ('\'', '´'),
  84            ('\\', '#'),
  85            (']', 'ä'),
  86            ('^', '&'),
  87            ('`', '<'),
  88            ('{', 'Ö'),
  89            ('|', '\''),
  90            ('}', 'Ä'),
  91            ('~', '>'),
  92        ],
  93        "com.apple.keylayout.Albanian" => &[
  94            ('"', '\''),
  95            (':', 'Ç'),
  96            (';', 'ç'),
  97            ('<', ';'),
  98            ('>', ':'),
  99            ('@', '"'),
 100            ('\'', '@'),
 101            ('\\', 'ë'),
 102            ('`', '<'),
 103            ('|', 'Ë'),
 104            ('~', '>'),
 105        ],
 106        "com.apple.keylayout.Austrian" => &[
 107            ('"', '`'),
 108            ('#', '§'),
 109            ('&', '/'),
 110            ('(', ')'),
 111            (')', '='),
 112            ('*', '('),
 113            ('/', 'ß'),
 114            (':', 'Ü'),
 115            (';', 'ü'),
 116            ('<', ';'),
 117            ('=', '*'),
 118            ('>', ':'),
 119            ('@', '"'),
 120            ('[', 'ö'),
 121            ('\'', '´'),
 122            ('\\', '#'),
 123            (']', 'ä'),
 124            ('^', '&'),
 125            ('`', '<'),
 126            ('{', 'Ö'),
 127            ('|', '\''),
 128            ('}', 'Ä'),
 129            ('~', '>'),
 130        ],
 131        "com.apple.keylayout.Azeri" => &[
 132            ('"', 'Ə'),
 133            (',', 'ç'),
 134            ('.', 'ş'),
 135            ('/', '.'),
 136            (':', 'I'),
 137            (';', 'ı'),
 138            ('<', 'Ç'),
 139            ('>', 'Ş'),
 140            ('?', ','),
 141            ('W', 'Ü'),
 142            ('[', 'ö'),
 143            ('\'', 'ə'),
 144            (']', 'ğ'),
 145            ('w', 'ü'),
 146            ('{', 'Ö'),
 147            ('|', '/'),
 148            ('}', 'Ğ'),
 149        ],
 150        "com.apple.keylayout.Belgian" => &[
 151            ('!', '1'),
 152            ('"', '%'),
 153            ('#', '3'),
 154            ('$', '4'),
 155            ('%', '5'),
 156            ('&', '7'),
 157            ('(', '9'),
 158            (')', '0'),
 159            ('*', '8'),
 160            ('.', ';'),
 161            ('/', ':'),
 162            ('0', 'à'),
 163            ('1', '&'),
 164            ('2', 'é'),
 165            ('3', '"'),
 166            ('4', '\''),
 167            ('5', '('),
 168            ('6', '§'),
 169            ('7', 'è'),
 170            ('8', '!'),
 171            ('9', 'ç'),
 172            (':', '°'),
 173            (';', ')'),
 174            ('<', '.'),
 175            ('>', '/'),
 176            ('@', '2'),
 177            ('[', '^'),
 178            ('\'', 'ù'),
 179            ('\\', '`'),
 180            (']', '$'),
 181            ('^', '6'),
 182            ('`', '<'),
 183            ('{', '¨'),
 184            ('|', '£'),
 185            ('}', '*'),
 186            ('~', '>'),
 187        ],
 188        "com.apple.keylayout.Brazilian-ABNT2" => &[
 189            ('"', '`'),
 190            ('/', 'ç'),
 191            ('?', 'Ç'),
 192            ('\'', '´'),
 193            ('\\', '~'),
 194            ('^', '¨'),
 195            ('`', '\''),
 196            ('|', '^'),
 197            ('~', '"'),
 198        ],
 199        "com.apple.keylayout.Brazilian-Pro" => &[('^', 'ˆ'), ('~', '˜')],
 200        "com.apple.keylayout.British" => &[('#', '£')],
 201        "com.apple.keylayout.Canadian-CSA" => &[
 202            ('"', 'È'),
 203            ('/', 'é'),
 204            ('<', '\''),
 205            ('>', '"'),
 206            ('?', 'É'),
 207            ('[', '^'),
 208            ('\'', 'è'),
 209            ('\\', 'à'),
 210            (']', 'ç'),
 211            ('`', 'ù'),
 212            ('{', '¨'),
 213            ('|', 'À'),
 214            ('}', 'Ç'),
 215            ('~', 'Ù'),
 216        ],
 217        "com.apple.keylayout.Croatian" => &[
 218            ('"', 'Ć'),
 219            ('&', '\''),
 220            ('(', ')'),
 221            (')', '='),
 222            ('*', '('),
 223            (':', 'Č'),
 224            (';', 'č'),
 225            ('<', ';'),
 226            ('=', '*'),
 227            ('>', ':'),
 228            ('@', '"'),
 229            ('[', 'š'),
 230            ('\'', 'ć'),
 231            ('\\', 'ž'),
 232            (']', 'đ'),
 233            ('^', '&'),
 234            ('`', '<'),
 235            ('{', 'Š'),
 236            ('|', 'Ž'),
 237            ('}', 'Đ'),
 238            ('~', '>'),
 239        ],
 240        "com.apple.keylayout.Croatian-PC" => &[
 241            ('"', 'Ć'),
 242            ('&', '/'),
 243            ('(', ')'),
 244            (')', '='),
 245            ('*', '('),
 246            ('/', '\''),
 247            (':', 'Č'),
 248            (';', 'č'),
 249            ('<', ';'),
 250            ('=', '*'),
 251            ('>', ':'),
 252            ('@', '"'),
 253            ('[', 'š'),
 254            ('\'', 'ć'),
 255            ('\\', 'ž'),
 256            (']', 'đ'),
 257            ('^', '&'),
 258            ('`', '<'),
 259            ('{', 'Š'),
 260            ('|', 'Ž'),
 261            ('}', 'Đ'),
 262            ('~', '>'),
 263        ],
 264        "com.apple.keylayout.Czech" => &[
 265            ('!', '1'),
 266            ('"', '!'),
 267            ('#', '3'),
 268            ('$', '4'),
 269            ('%', '5'),
 270            ('&', '7'),
 271            ('(', '9'),
 272            (')', '0'),
 273            ('*', '8'),
 274            ('+', '%'),
 275            ('/', '\''),
 276            ('0', 'é'),
 277            ('1', '+'),
 278            ('2', 'ě'),
 279            ('3', 'š'),
 280            ('4', 'č'),
 281            ('5', 'ř'),
 282            ('6', 'ž'),
 283            ('7', 'ý'),
 284            ('8', 'á'),
 285            ('9', 'í'),
 286            (':', '"'),
 287            (';', 'ů'),
 288            ('<', '?'),
 289            ('>', ':'),
 290            ('?', 'ˇ'),
 291            ('@', '2'),
 292            ('[', 'ú'),
 293            ('\'', '§'),
 294            (']', ')'),
 295            ('^', '6'),
 296            ('`', '¨'),
 297            ('{', 'Ú'),
 298            ('}', '('),
 299            ('~', '`'),
 300        ],
 301        "com.apple.keylayout.Czech-QWERTY" => &[
 302            ('!', '1'),
 303            ('"', '!'),
 304            ('#', '3'),
 305            ('$', '4'),
 306            ('%', '5'),
 307            ('&', '7'),
 308            ('(', '9'),
 309            (')', '0'),
 310            ('*', '8'),
 311            ('+', '%'),
 312            ('/', '\''),
 313            ('0', 'é'),
 314            ('1', '+'),
 315            ('2', 'ě'),
 316            ('3', 'š'),
 317            ('4', 'č'),
 318            ('5', 'ř'),
 319            ('6', 'ž'),
 320            ('7', 'ý'),
 321            ('8', 'á'),
 322            ('9', 'í'),
 323            (':', '"'),
 324            (';', 'ů'),
 325            ('<', '?'),
 326            ('>', ':'),
 327            ('?', 'ˇ'),
 328            ('@', '2'),
 329            ('[', 'ú'),
 330            ('\'', '§'),
 331            (']', ')'),
 332            ('^', '6'),
 333            ('`', '¨'),
 334            ('{', 'Ú'),
 335            ('}', '('),
 336            ('~', '`'),
 337        ],
 338        "com.apple.keylayout.Danish" => &[
 339            ('"', '^'),
 340            ('$', '€'),
 341            ('&', '/'),
 342            ('(', ')'),
 343            (')', '='),
 344            ('*', '('),
 345            ('/', '´'),
 346            (':', 'Å'),
 347            (';', 'å'),
 348            ('<', ';'),
 349            ('=', '`'),
 350            ('>', ':'),
 351            ('@', '"'),
 352            ('[', 'æ'),
 353            ('\'', '¨'),
 354            ('\\', '\''),
 355            (']', 'ø'),
 356            ('^', '&'),
 357            ('`', '<'),
 358            ('{', 'Æ'),
 359            ('|', '*'),
 360            ('}', 'Ø'),
 361            ('~', '>'),
 362        ],
 363        "com.apple.keylayout.Faroese" => &[
 364            ('"', 'Ø'),
 365            ('$', '€'),
 366            ('&', '/'),
 367            ('(', ')'),
 368            (')', '='),
 369            ('*', '('),
 370            ('/', '´'),
 371            (':', 'Æ'),
 372            (';', 'æ'),
 373            ('<', ';'),
 374            ('=', '`'),
 375            ('>', ':'),
 376            ('@', '"'),
 377            ('[', 'å'),
 378            ('\'', 'ø'),
 379            ('\\', '\''),
 380            (']', 'ð'),
 381            ('^', '&'),
 382            ('`', '<'),
 383            ('{', 'Å'),
 384            ('|', '*'),
 385            ('}', 'Ð'),
 386            ('~', '>'),
 387        ],
 388        "com.apple.keylayout.Finnish" => &[
 389            ('"', '^'),
 390            ('$', '€'),
 391            ('&', '/'),
 392            ('(', ')'),
 393            (')', '='),
 394            ('*', '('),
 395            ('/', '´'),
 396            (':', 'Å'),
 397            (';', 'å'),
 398            ('<', ';'),
 399            ('=', '`'),
 400            ('>', ':'),
 401            ('@', '"'),
 402            ('[', 'ö'),
 403            ('\'', '¨'),
 404            ('\\', '\''),
 405            (']', 'ä'),
 406            ('^', '&'),
 407            ('`', '<'),
 408            ('{', 'Ö'),
 409            ('|', '*'),
 410            ('}', 'Ä'),
 411            ('~', '>'),
 412        ],
 413        "com.apple.keylayout.FinnishExtended" => &[
 414            ('"', 'ˆ'),
 415            ('$', '€'),
 416            ('&', '/'),
 417            ('(', ')'),
 418            (')', '='),
 419            ('*', '('),
 420            ('/', '´'),
 421            (':', 'Å'),
 422            (';', 'å'),
 423            ('<', ';'),
 424            ('=', '`'),
 425            ('>', ':'),
 426            ('@', '"'),
 427            ('[', 'ö'),
 428            ('\'', '¨'),
 429            ('\\', '\''),
 430            (']', 'ä'),
 431            ('^', '&'),
 432            ('`', '<'),
 433            ('{', 'Ö'),
 434            ('|', '*'),
 435            ('}', 'Ä'),
 436            ('~', '>'),
 437        ],
 438        "com.apple.keylayout.FinnishSami-PC" => &[
 439            ('"', 'ˆ'),
 440            ('&', '/'),
 441            ('(', ')'),
 442            (')', '='),
 443            ('*', '('),
 444            ('/', '´'),
 445            (':', 'Å'),
 446            (';', 'å'),
 447            ('<', ';'),
 448            ('=', '`'),
 449            ('>', ':'),
 450            ('@', '"'),
 451            ('[', 'ö'),
 452            ('\'', '¨'),
 453            ('\\', '@'),
 454            (']', 'ä'),
 455            ('^', '&'),
 456            ('`', '<'),
 457            ('{', 'Ö'),
 458            ('|', '*'),
 459            ('}', 'Ä'),
 460            ('~', '>'),
 461        ],
 462        "com.apple.keylayout.French" => &[
 463            ('!', '1'),
 464            ('"', '%'),
 465            ('#', '3'),
 466            ('$', '4'),
 467            ('%', '5'),
 468            ('&', '7'),
 469            ('(', '9'),
 470            (')', '0'),
 471            ('*', '8'),
 472            ('.', ';'),
 473            ('/', ':'),
 474            ('0', 'à'),
 475            ('1', '&'),
 476            ('2', 'é'),
 477            ('3', '"'),
 478            ('4', '\''),
 479            ('5', '('),
 480            ('6', '§'),
 481            ('7', 'è'),
 482            ('8', '!'),
 483            ('9', 'ç'),
 484            (':', '°'),
 485            (';', ')'),
 486            ('<', '.'),
 487            ('>', '/'),
 488            ('@', '2'),
 489            ('[', '^'),
 490            ('\'', 'ù'),
 491            ('\\', '`'),
 492            (']', '$'),
 493            ('^', '6'),
 494            ('`', '<'),
 495            ('{', '¨'),
 496            ('|', '£'),
 497            ('}', '*'),
 498            ('~', '>'),
 499        ],
 500        "com.apple.keylayout.French-PC" => &[
 501            ('!', '1'),
 502            ('"', '%'),
 503            ('#', '3'),
 504            ('$', '4'),
 505            ('%', '5'),
 506            ('&', '7'),
 507            ('(', '9'),
 508            (')', '0'),
 509            ('*', '8'),
 510            ('-', ')'),
 511            ('.', ';'),
 512            ('/', ':'),
 513            ('0', 'à'),
 514            ('1', '&'),
 515            ('2', 'é'),
 516            ('3', '"'),
 517            ('4', '\''),
 518            ('5', '('),
 519            ('6', '-'),
 520            ('7', 'è'),
 521            ('8', '_'),
 522            ('9', 'ç'),
 523            (':', '§'),
 524            (';', '!'),
 525            ('<', '.'),
 526            ('>', '/'),
 527            ('@', '2'),
 528            ('[', '^'),
 529            ('\'', 'ù'),
 530            ('\\', '*'),
 531            (']', '$'),
 532            ('^', '6'),
 533            ('_', '°'),
 534            ('`', '<'),
 535            ('{', '¨'),
 536            ('|', 'μ'),
 537            ('}', '£'),
 538            ('~', '>'),
 539        ],
 540        "com.apple.keylayout.French-numerical" => &[
 541            ('!', '1'),
 542            ('"', '%'),
 543            ('#', '3'),
 544            ('$', '4'),
 545            ('%', '5'),
 546            ('&', '7'),
 547            ('(', '9'),
 548            (')', '0'),
 549            ('*', '8'),
 550            ('.', ';'),
 551            ('/', ':'),
 552            ('0', 'à'),
 553            ('1', '&'),
 554            ('2', 'é'),
 555            ('3', '"'),
 556            ('4', '\''),
 557            ('5', '('),
 558            ('6', '§'),
 559            ('7', 'è'),
 560            ('8', '!'),
 561            ('9', 'ç'),
 562            (':', '°'),
 563            (';', ')'),
 564            ('<', '.'),
 565            ('>', '/'),
 566            ('@', '2'),
 567            ('[', '^'),
 568            ('\'', 'ù'),
 569            ('\\', '`'),
 570            (']', '$'),
 571            ('^', '6'),
 572            ('`', '<'),
 573            ('{', '¨'),
 574            ('|', '£'),
 575            ('}', '*'),
 576            ('~', '>'),
 577        ],
 578        "com.apple.keylayout.German" => &[
 579            ('"', '`'),
 580            ('#', '§'),
 581            ('&', '/'),
 582            ('(', ')'),
 583            (')', '='),
 584            ('*', '('),
 585            ('/', 'ß'),
 586            (':', 'Ü'),
 587            (';', 'ü'),
 588            ('<', ';'),
 589            ('=', '*'),
 590            ('>', ':'),
 591            ('@', '"'),
 592            ('[', 'ö'),
 593            ('\'', '´'),
 594            ('\\', '#'),
 595            (']', 'ä'),
 596            ('^', '&'),
 597            ('`', '<'),
 598            ('{', 'Ö'),
 599            ('|', '\''),
 600            ('}', 'Ä'),
 601            ('~', '>'),
 602        ],
 603        "com.apple.keylayout.German-DIN-2137" => &[
 604            ('"', '`'),
 605            ('#', '§'),
 606            ('&', '/'),
 607            ('(', ')'),
 608            (')', '='),
 609            ('*', '('),
 610            ('/', 'ß'),
 611            (':', 'Ü'),
 612            (';', 'ü'),
 613            ('<', ';'),
 614            ('=', '*'),
 615            ('>', ':'),
 616            ('@', '"'),
 617            ('[', 'ö'),
 618            ('\'', '´'),
 619            ('\\', '#'),
 620            (']', 'ä'),
 621            ('^', '&'),
 622            ('`', '<'),
 623            ('{', 'Ö'),
 624            ('|', '\''),
 625            ('}', 'Ä'),
 626            ('~', '>'),
 627        ],
 628        "com.apple.keylayout.Hawaiian" => &[('\'', 'ʻ')],
 629        "com.apple.keylayout.Hungarian" => &[
 630            ('!', '\''),
 631            ('"', 'Á'),
 632            ('#', '+'),
 633            ('$', '!'),
 634            ('&', '='),
 635            ('(', ')'),
 636            (')', 'Ö'),
 637            ('*', '('),
 638            ('+', 'Ó'),
 639            ('/', 'ü'),
 640            ('0', 'ö'),
 641            (':', 'É'),
 642            (';', 'é'),
 643            ('<', 'Ü'),
 644            ('=', 'ó'),
 645            ('>', ':'),
 646            ('@', '"'),
 647            ('[', 'ő'),
 648            ('\'', 'á'),
 649            ('\\', 'ű'),
 650            (']', 'ú'),
 651            ('^', '/'),
 652            ('`', 'í'),
 653            ('{', 'Ő'),
 654            ('|', 'Ű'),
 655            ('}', 'Ú'),
 656            ('~', 'Í'),
 657        ],
 658        "com.apple.keylayout.Hungarian-QWERTY" => &[
 659            ('!', '\''),
 660            ('"', 'Á'),
 661            ('#', '+'),
 662            ('$', '!'),
 663            ('&', '='),
 664            ('(', ')'),
 665            (')', 'Ö'),
 666            ('*', '('),
 667            ('+', 'Ó'),
 668            ('/', 'ü'),
 669            ('0', 'ö'),
 670            (':', 'É'),
 671            (';', 'é'),
 672            ('<', 'Ü'),
 673            ('=', 'ó'),
 674            ('>', ':'),
 675            ('@', '"'),
 676            ('[', 'ő'),
 677            ('\'', 'á'),
 678            ('\\', 'ű'),
 679            (']', 'ú'),
 680            ('^', '/'),
 681            ('`', 'í'),
 682            ('{', 'Ő'),
 683            ('|', 'Ű'),
 684            ('}', 'Ú'),
 685            ('~', 'Í'),
 686        ],
 687        "com.apple.keylayout.Icelandic" => &[
 688            ('"', 'Ö'),
 689            ('&', '/'),
 690            ('(', ')'),
 691            (')', '='),
 692            ('*', '('),
 693            ('/', '\''),
 694            (':', 'Ð'),
 695            (';', 'ð'),
 696            ('<', ';'),
 697            ('=', '*'),
 698            ('>', ':'),
 699            ('@', '"'),
 700            ('[', 'æ'),
 701            ('\'', 'ö'),
 702            ('\\', 'þ'),
 703            (']', '´'),
 704            ('^', '&'),
 705            ('`', '<'),
 706            ('{', 'Æ'),
 707            ('|', 'Þ'),
 708            ('}', '´'),
 709            ('~', '>'),
 710        ],
 711        "com.apple.keylayout.Irish" => &[('#', '£')],
 712        "com.apple.keylayout.IrishExtended" => &[('#', '£')],
 713        "com.apple.keylayout.Italian" => &[
 714            ('!', '1'),
 715            ('"', '%'),
 716            ('#', '3'),
 717            ('$', '4'),
 718            ('%', '5'),
 719            ('&', '7'),
 720            ('(', '9'),
 721            (')', '0'),
 722            ('*', '8'),
 723            (',', ';'),
 724            ('.', ':'),
 725            ('/', ','),
 726            ('0', 'é'),
 727            ('1', '&'),
 728            ('2', '"'),
 729            ('3', '\''),
 730            ('4', '('),
 731            ('5', 'ç'),
 732            ('6', 'è'),
 733            ('7', ')'),
 734            ('8', '£'),
 735            ('9', 'à'),
 736            (':', '!'),
 737            (';', 'ò'),
 738            ('<', '.'),
 739            ('>', '/'),
 740            ('@', '2'),
 741            ('[', 'ì'),
 742            ('\'', 'ù'),
 743            ('\\', '§'),
 744            (']', '$'),
 745            ('^', '6'),
 746            ('`', '<'),
 747            ('{', '^'),
 748            ('|', '°'),
 749            ('}', '*'),
 750            ('~', '>'),
 751        ],
 752        "com.apple.keylayout.Italian-Pro" => &[
 753            ('"', '^'),
 754            ('#', '£'),
 755            ('&', '/'),
 756            ('(', ')'),
 757            (')', '='),
 758            ('*', '('),
 759            ('/', '\''),
 760            (':', 'é'),
 761            (';', 'è'),
 762            ('<', ';'),
 763            ('=', '*'),
 764            ('>', ':'),
 765            ('@', '"'),
 766            ('[', 'ò'),
 767            ('\'', 'ì'),
 768            ('\\', 'ù'),
 769            (']', 'à'),
 770            ('^', '&'),
 771            ('`', '<'),
 772            ('{', 'ç'),
 773            ('|', '§'),
 774            ('}', '°'),
 775            ('~', '>'),
 776        ],
 777        "com.apple.keylayout.LatinAmerican" => &[
 778            ('"', '¨'),
 779            ('&', '/'),
 780            ('(', ')'),
 781            (')', '='),
 782            ('*', '('),
 783            ('/', '\''),
 784            (':', 'Ñ'),
 785            (';', 'ñ'),
 786            ('<', ';'),
 787            ('=', '*'),
 788            ('>', ':'),
 789            ('@', '"'),
 790            ('[', '{'),
 791            ('\'', '´'),
 792            ('\\', '¿'),
 793            (']', '}'),
 794            ('^', '&'),
 795            ('`', '<'),
 796            ('{', '['),
 797            ('|', '¡'),
 798            ('}', ']'),
 799            ('~', '>'),
 800        ],
 801        "com.apple.keylayout.Lithuanian" => &[
 802            ('!', 'Ą'),
 803            ('#', 'Ę'),
 804            ('$', 'Ė'),
 805            ('%', 'Į'),
 806            ('&', 'Ų'),
 807            ('*', 'Ū'),
 808            ('+', 'Ž'),
 809            ('1', 'ą'),
 810            ('2', 'č'),
 811            ('3', 'ę'),
 812            ('4', 'ė'),
 813            ('5', 'į'),
 814            ('6', 'š'),
 815            ('7', 'ų'),
 816            ('8', 'ū'),
 817            ('=', 'ž'),
 818            ('@', 'Č'),
 819            ('^', 'Š'),
 820        ],
 821        "com.apple.keylayout.Maltese" => &[
 822            ('#', '£'),
 823            ('[', 'ġ'),
 824            (']', 'ħ'),
 825            ('`', 'ż'),
 826            ('{', 'Ġ'),
 827            ('}', 'Ħ'),
 828            ('~', 'Ż'),
 829        ],
 830        "com.apple.keylayout.NorthernSami" => &[
 831            ('"', 'Ŋ'),
 832            ('&', '/'),
 833            ('(', ')'),
 834            (')', '='),
 835            ('*', '('),
 836            ('/', '´'),
 837            (':', 'Å'),
 838            (';', 'å'),
 839            ('<', ';'),
 840            ('=', '`'),
 841            ('>', ':'),
 842            ('@', '"'),
 843            ('Q', 'Á'),
 844            ('W', 'Š'),
 845            ('X', 'Č'),
 846            ('[', 'ø'),
 847            ('\'', 'ŋ'),
 848            ('\\', 'đ'),
 849            (']', 'æ'),
 850            ('^', '&'),
 851            ('`', 'ž'),
 852            ('q', 'á'),
 853            ('w', 'š'),
 854            ('x', 'č'),
 855            ('{', 'Ø'),
 856            ('|', 'Đ'),
 857            ('}', 'Æ'),
 858            ('~', 'Ž'),
 859        ],
 860        "com.apple.keylayout.Norwegian" => &[
 861            ('"', '^'),
 862            ('&', '/'),
 863            ('(', ')'),
 864            (')', '='),
 865            ('*', '('),
 866            ('/', '´'),
 867            (':', 'Å'),
 868            (';', 'å'),
 869            ('<', ';'),
 870            ('=', '`'),
 871            ('>', ':'),
 872            ('@', '"'),
 873            ('[', 'ø'),
 874            ('\'', '¨'),
 875            ('\\', '@'),
 876            (']', 'æ'),
 877            ('^', '&'),
 878            ('`', '<'),
 879            ('{', 'Ø'),
 880            ('|', '*'),
 881            ('}', 'Æ'),
 882            ('~', '>'),
 883        ],
 884        "com.apple.keylayout.NorwegianExtended" => &[('^', 'ˆ'), ('~', '˜')],
 885        "com.apple.keylayout.NorwegianSami-PC" => &[
 886            ('"', 'ˆ'),
 887            ('&', '/'),
 888            ('(', ')'),
 889            (')', '='),
 890            ('*', '('),
 891            ('/', '´'),
 892            (':', 'Å'),
 893            (';', 'å'),
 894            ('<', ';'),
 895            ('=', '`'),
 896            ('>', ':'),
 897            ('@', '"'),
 898            ('[', 'ø'),
 899            ('\'', '¨'),
 900            ('\\', '@'),
 901            (']', 'æ'),
 902            ('^', '&'),
 903            ('`', '<'),
 904            ('{', 'Ø'),
 905            ('|', '*'),
 906            ('}', 'Æ'),
 907            ('~', '>'),
 908        ],
 909        "com.apple.keylayout.Polish" => &[
 910            ('!', '§'),
 911            ('"', 'ę'),
 912            ('#', '!'),
 913            ('$', '?'),
 914            ('%', '+'),
 915            ('&', ':'),
 916            ('(', '/'),
 917            (')', '"'),
 918            ('*', '_'),
 919            ('+', ']'),
 920            (',', '.'),
 921            ('.', ','),
 922            ('/', 'ż'),
 923            (':', 'Ł'),
 924            (';', 'ł'),
 925            ('<', 'ś'),
 926            ('=', '['),
 927            ('>', 'ń'),
 928            ('?', 'Ż'),
 929            ('@', '%'),
 930            ('[', 'ó'),
 931            ('\'', 'ą'),
 932            ('\\', ';'),
 933            (']', '('),
 934            ('^', '='),
 935            ('_', 'ć'),
 936            ('`', '<'),
 937            ('{', 'ź'),
 938            ('|', '$'),
 939            ('}', ')'),
 940            ('~', '>'),
 941        ],
 942        "com.apple.keylayout.Portuguese" => &[
 943            ('"', '`'),
 944            ('&', '/'),
 945            ('(', ')'),
 946            (')', '='),
 947            ('*', '('),
 948            ('/', '\''),
 949            (':', 'ª'),
 950            (';', 'º'),
 951            ('<', ';'),
 952            ('=', '*'),
 953            ('>', ':'),
 954            ('@', '"'),
 955            ('[', 'ç'),
 956            ('\'', '´'),
 957            (']', '~'),
 958            ('^', '&'),
 959            ('`', '<'),
 960            ('{', 'Ç'),
 961            ('}', '^'),
 962            ('~', '>'),
 963        ],
 964        "com.apple.keylayout.Sami-PC" => &[
 965            ('"', 'Ŋ'),
 966            ('&', '/'),
 967            ('(', ')'),
 968            (')', '='),
 969            ('*', '('),
 970            ('/', '´'),
 971            (':', 'Å'),
 972            (';', 'å'),
 973            ('<', ';'),
 974            ('=', '`'),
 975            ('>', ':'),
 976            ('@', '"'),
 977            ('Q', 'Á'),
 978            ('W', 'Š'),
 979            ('X', 'Č'),
 980            ('[', 'ø'),
 981            ('\'', 'ŋ'),
 982            ('\\', 'đ'),
 983            (']', 'æ'),
 984            ('^', '&'),
 985            ('`', 'ž'),
 986            ('q', 'á'),
 987            ('w', 'š'),
 988            ('x', 'č'),
 989            ('{', 'Ø'),
 990            ('|', 'Đ'),
 991            ('}', 'Æ'),
 992            ('~', 'Ž'),
 993        ],
 994        "com.apple.keylayout.Serbian-Latin" => &[
 995            ('"', 'Ć'),
 996            ('&', '\''),
 997            ('(', ')'),
 998            (')', '='),
 999            ('*', '('),
1000            (':', 'Č'),
1001            (';', 'č'),
1002            ('<', ';'),
1003            ('=', '*'),
1004            ('>', ':'),
1005            ('@', '"'),
1006            ('[', 'š'),
1007            ('\'', 'ć'),
1008            ('\\', 'ž'),
1009            (']', 'đ'),
1010            ('^', '&'),
1011            ('`', '<'),
1012            ('{', 'Š'),
1013            ('|', 'Ž'),
1014            ('}', 'Đ'),
1015            ('~', '>'),
1016        ],
1017        "com.apple.keylayout.Slovak" => &[
1018            ('!', '1'),
1019            ('"', '!'),
1020            ('#', '3'),
1021            ('$', '4'),
1022            ('%', '5'),
1023            ('&', '7'),
1024            ('(', '9'),
1025            (')', '0'),
1026            ('*', '8'),
1027            ('+', '%'),
1028            ('/', '\''),
1029            ('0', 'é'),
1030            ('1', '+'),
1031            ('2', 'ľ'),
1032            ('3', 'š'),
1033            ('4', 'č'),
1034            ('5', 'ť'),
1035            ('6', 'ž'),
1036            ('7', 'ý'),
1037            ('8', 'á'),
1038            ('9', 'í'),
1039            (':', '"'),
1040            (';', 'ô'),
1041            ('<', '?'),
1042            ('>', ':'),
1043            ('?', 'ˇ'),
1044            ('@', '2'),
1045            ('[', 'ú'),
1046            ('\'', '§'),
1047            (']', 'ä'),
1048            ('^', '6'),
1049            ('`', 'ň'),
1050            ('{', 'Ú'),
1051            ('}', 'Ä'),
1052            ('~', 'Ň'),
1053        ],
1054        "com.apple.keylayout.Slovak-QWERTY" => &[
1055            ('!', '1'),
1056            ('"', '!'),
1057            ('#', '3'),
1058            ('$', '4'),
1059            ('%', '5'),
1060            ('&', '7'),
1061            ('(', '9'),
1062            (')', '0'),
1063            ('*', '8'),
1064            ('+', '%'),
1065            ('/', '\''),
1066            ('0', 'é'),
1067            ('1', '+'),
1068            ('2', 'ľ'),
1069            ('3', 'š'),
1070            ('4', 'č'),
1071            ('5', 'ť'),
1072            ('6', 'ž'),
1073            ('7', 'ý'),
1074            ('8', 'á'),
1075            ('9', 'í'),
1076            (':', '"'),
1077            (';', 'ô'),
1078            ('<', '?'),
1079            ('>', ':'),
1080            ('?', 'ˇ'),
1081            ('@', '2'),
1082            ('[', 'ú'),
1083            ('\'', '§'),
1084            (']', 'ä'),
1085            ('^', '6'),
1086            ('`', 'ň'),
1087            ('{', 'Ú'),
1088            ('}', 'Ä'),
1089            ('~', 'Ň'),
1090        ],
1091        "com.apple.keylayout.Slovenian" => &[
1092            ('"', 'Ć'),
1093            ('&', '\''),
1094            ('(', ')'),
1095            (')', '='),
1096            ('*', '('),
1097            (':', 'Č'),
1098            (';', 'č'),
1099            ('<', ';'),
1100            ('=', '*'),
1101            ('>', ':'),
1102            ('@', '"'),
1103            ('[', 'š'),
1104            ('\'', 'ć'),
1105            ('\\', 'ž'),
1106            (']', 'đ'),
1107            ('^', '&'),
1108            ('`', '<'),
1109            ('{', 'Š'),
1110            ('|', 'Ž'),
1111            ('}', 'Đ'),
1112            ('~', '>'),
1113        ],
1114        "com.apple.keylayout.Spanish" => &[
1115            ('!', '¡'),
1116            ('"', '¨'),
1117            ('.', 'ç'),
1118            ('/', '.'),
1119            (':', 'º'),
1120            (';', '´'),
1121            ('<', '¿'),
1122            ('>', 'Ç'),
1123            ('@', '!'),
1124            ('[', 'ñ'),
1125            ('\'', '`'),
1126            ('\\', '\''),
1127            (']', ';'),
1128            ('^', '/'),
1129            ('`', '<'),
1130            ('{', 'Ñ'),
1131            ('|', '"'),
1132            ('}', ':'),
1133            ('~', '>'),
1134        ],
1135        "com.apple.keylayout.Spanish-ISO" => &[
1136            ('"', '¨'),
1137            ('#', '·'),
1138            ('&', '/'),
1139            ('(', ')'),
1140            (')', '='),
1141            ('*', '('),
1142            ('.', 'ç'),
1143            ('/', '.'),
1144            (':', 'º'),
1145            (';', '´'),
1146            ('<', '¿'),
1147            ('>', 'Ç'),
1148            ('@', '"'),
1149            ('[', 'ñ'),
1150            ('\'', '`'),
1151            ('\\', '\''),
1152            (']', ';'),
1153            ('^', '&'),
1154            ('`', '<'),
1155            ('{', 'Ñ'),
1156            ('|', '"'),
1157            ('}', '`'),
1158            ('~', '>'),
1159        ],
1160        "com.apple.keylayout.Swedish" => &[
1161            ('"', '^'),
1162            ('$', '€'),
1163            ('&', '/'),
1164            ('(', ')'),
1165            (')', '='),
1166            ('*', '('),
1167            ('/', '´'),
1168            (':', 'Å'),
1169            (';', 'å'),
1170            ('<', ';'),
1171            ('=', '`'),
1172            ('>', ':'),
1173            ('@', '"'),
1174            ('[', 'ö'),
1175            ('\'', '¨'),
1176            ('\\', '\''),
1177            (']', 'ä'),
1178            ('^', '&'),
1179            ('`', '<'),
1180            ('{', 'Ö'),
1181            ('|', '*'),
1182            ('}', 'Ä'),
1183            ('~', '>'),
1184        ],
1185        "com.apple.keylayout.Swedish-Pro" => &[
1186            ('"', '^'),
1187            ('$', '€'),
1188            ('&', '/'),
1189            ('(', ')'),
1190            (')', '='),
1191            ('*', '('),
1192            ('/', '´'),
1193            (':', 'Å'),
1194            (';', 'å'),
1195            ('<', ';'),
1196            ('=', '`'),
1197            ('>', ':'),
1198            ('@', '"'),
1199            ('[', 'ö'),
1200            ('\'', '¨'),
1201            ('\\', '\''),
1202            (']', 'ä'),
1203            ('^', '&'),
1204            ('`', '<'),
1205            ('{', 'Ö'),
1206            ('|', '*'),
1207            ('}', 'Ä'),
1208            ('~', '>'),
1209        ],
1210        "com.apple.keylayout.SwedishSami-PC" => &[
1211            ('"', 'ˆ'),
1212            ('&', '/'),
1213            ('(', ')'),
1214            (')', '='),
1215            ('*', '('),
1216            ('/', '´'),
1217            (':', 'Å'),
1218            (';', 'å'),
1219            ('<', ';'),
1220            ('=', '`'),
1221            ('>', ':'),
1222            ('@', '"'),
1223            ('[', 'ö'),
1224            ('\'', '¨'),
1225            ('\\', '@'),
1226            (']', 'ä'),
1227            ('^', '&'),
1228            ('`', '<'),
1229            ('{', 'Ö'),
1230            ('|', '*'),
1231            ('}', 'Ä'),
1232            ('~', '>'),
1233        ],
1234        "com.apple.keylayout.SwissFrench" => &[
1235            ('!', '+'),
1236            ('"', '`'),
1237            ('#', '*'),
1238            ('$', 'ç'),
1239            ('&', '/'),
1240            ('(', ')'),
1241            (')', '='),
1242            ('*', '('),
1243            ('+', '!'),
1244            ('/', '\''),
1245            (':', 'ü'),
1246            (';', 'è'),
1247            ('<', ';'),
1248            ('=', '¨'),
1249            ('>', ':'),
1250            ('@', '"'),
1251            ('[', 'é'),
1252            ('\'', '^'),
1253            ('\\', '$'),
1254            (']', 'à'),
1255            ('^', '&'),
1256            ('`', '<'),
1257            ('{', 'ö'),
1258            ('|', '£'),
1259            ('}', 'ä'),
1260            ('~', '>'),
1261        ],
1262        "com.apple.keylayout.SwissGerman" => &[
1263            ('!', '+'),
1264            ('"', '`'),
1265            ('#', '*'),
1266            ('$', 'ç'),
1267            ('&', '/'),
1268            ('(', ')'),
1269            (')', '='),
1270            ('*', '('),
1271            ('+', '!'),
1272            ('/', '\''),
1273            (':', 'è'),
1274            (';', 'ü'),
1275            ('<', ';'),
1276            ('=', '¨'),
1277            ('>', ':'),
1278            ('@', '"'),
1279            ('[', 'ö'),
1280            ('\'', '^'),
1281            ('\\', '$'),
1282            (']', 'ä'),
1283            ('^', '&'),
1284            ('`', '<'),
1285            ('{', 'é'),
1286            ('|', '£'),
1287            ('}', 'à'),
1288            ('~', '>'),
1289        ],
1290        "com.apple.keylayout.Turkish" => &[
1291            ('"', '-'),
1292            ('#', '"'),
1293            ('$', '\''),
1294            ('%', '('),
1295            ('&', ')'),
1296            ('(', '%'),
1297            (')', ':'),
1298            ('*', '_'),
1299            (',', 'ö'),
1300            ('-', 'ş'),
1301            ('.', 'ç'),
1302            ('/', '.'),
1303            (':', '$'),
1304            ('<', 'Ö'),
1305            ('>', 'Ç'),
1306            ('@', '*'),
1307            ('[', 'ğ'),
1308            ('\'', ','),
1309            ('\\', 'ü'),
1310            (']', 'ı'),
1311            ('^', '/'),
1312            ('_', 'Ş'),
1313            ('`', '<'),
1314            ('{', 'Ğ'),
1315            ('|', 'Ü'),
1316            ('}', 'I'),
1317            ('~', '>'),
1318        ],
1319        "com.apple.keylayout.Turkish-QWERTY-PC" => &[
1320            ('"', 'I'),
1321            ('#', '^'),
1322            ('$', '+'),
1323            ('&', '/'),
1324            ('(', ')'),
1325            (')', '='),
1326            ('*', '('),
1327            ('+', ':'),
1328            (',', 'ö'),
1329            ('.', 'ç'),
1330            ('/', '*'),
1331            (':', 'Ş'),
1332            (';', 'ş'),
1333            ('<', 'Ö'),
1334            ('=', '.'),
1335            ('>', 'Ç'),
1336            ('@', '\''),
1337            ('[', 'ğ'),
1338            ('\'', 'ı'),
1339            ('\\', ','),
1340            (']', 'ü'),
1341            ('^', '&'),
1342            ('`', '<'),
1343            ('{', 'Ğ'),
1344            ('|', ';'),
1345            ('}', 'Ü'),
1346            ('~', '>'),
1347        ],
1348        "com.apple.keylayout.Turkish-Standard" => &[
1349            ('"', 'Ş'),
1350            ('#', '^'),
1351            ('&', '\''),
1352            ('(', ')'),
1353            (')', '='),
1354            ('*', '('),
1355            (',', '.'),
1356            ('.', ','),
1357            (':', 'Ç'),
1358            (';', 'ç'),
1359            ('<', ':'),
1360            ('=', '*'),
1361            ('>', ';'),
1362            ('@', '"'),
1363            ('[', 'ğ'),
1364            ('\'', 'ş'),
1365            ('\\', 'ü'),
1366            (']', 'ı'),
1367            ('^', '&'),
1368            ('`', 'ö'),
1369            ('{', 'Ğ'),
1370            ('|', 'Ü'),
1371            ('}', 'I'),
1372            ('~', 'Ö'),
1373        ],
1374        "com.apple.keylayout.Turkmen" => &[
1375            ('C', 'Ç'),
1376            ('Q', 'Ä'),
1377            ('V', 'Ý'),
1378            ('X', 'Ü'),
1379            ('[', 'ň'),
1380            ('\\', 'ş'),
1381            (']', 'ö'),
1382            ('^', '№'),
1383            ('`', 'ž'),
1384            ('c', 'ç'),
1385            ('q', 'ä'),
1386            ('v', 'ý'),
1387            ('x', 'ü'),
1388            ('{', 'Ň'),
1389            ('|', 'Ş'),
1390            ('}', 'Ö'),
1391            ('~', 'Ž'),
1392        ],
1393        "com.apple.keylayout.USInternational-PC" => &[('^', 'ˆ'), ('~', '˜')],
1394        "com.apple.keylayout.Welsh" => &[('#', '£')],
1395
1396        _ => return None,
1397    };
1398
1399    Some(HashMap::from_iter(mappings.into_iter().cloned()))
1400}
1401
1402#[cfg(not(target_os = "macos"))]
1403pub fn get_key_equivalents(_layout: &str) -> Option<HashMap<char, char>> {
1404    None
1405}