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 mnemonic 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            ('"', 'ˆ'),
 886            ('&', '/'),
 887            ('(', ')'),
 888            (')', '='),
 889            ('*', '('),
 890            ('/', '´'),
 891            (':', 'Å'),
 892            (';', 'å'),
 893            ('<', ';'),
 894            ('=', '`'),
 895            ('>', ':'),
 896            ('@', '"'),
 897            ('[', 'ø'),
 898            ('\\', '@'),
 899            (']', 'æ'),
 900            ('`', '<'),
 901            ('}', 'Æ'),
 902            ('~', '>'),
 903        ],
 904        "com.apple.keylayout.NorwegianSami-PC" => &[
 905            ('"', 'ˆ'),
 906            ('&', '/'),
 907            ('(', ')'),
 908            (')', '='),
 909            ('*', '('),
 910            ('/', '´'),
 911            (':', 'Å'),
 912            (';', 'å'),
 913            ('<', ';'),
 914            ('=', '`'),
 915            ('>', ':'),
 916            ('@', '"'),
 917            ('[', 'ø'),
 918            ('\'', '¨'),
 919            ('\\', '@'),
 920            (']', 'æ'),
 921            ('^', '&'),
 922            ('`', '<'),
 923            ('{', 'Ø'),
 924            ('|', '*'),
 925            ('}', 'Æ'),
 926            ('~', '>'),
 927        ],
 928        "com.apple.keylayout.Polish" => &[
 929            ('!', '§'),
 930            ('"', 'ę'),
 931            ('#', '!'),
 932            ('$', '?'),
 933            ('%', '+'),
 934            ('&', ':'),
 935            ('(', '/'),
 936            (')', '"'),
 937            ('*', '_'),
 938            ('+', ']'),
 939            (',', '.'),
 940            ('.', ','),
 941            ('/', 'ż'),
 942            (':', 'Ł'),
 943            (';', 'ł'),
 944            ('<', 'ś'),
 945            ('=', '['),
 946            ('>', 'ń'),
 947            ('?', 'Ż'),
 948            ('@', '%'),
 949            ('[', 'ó'),
 950            ('\'', 'ą'),
 951            ('\\', ';'),
 952            (']', '('),
 953            ('^', '='),
 954            ('_', 'ć'),
 955            ('`', '<'),
 956            ('{', 'ź'),
 957            ('|', '$'),
 958            ('}', ')'),
 959            ('~', '>'),
 960        ],
 961        "com.apple.keylayout.Portuguese" => &[
 962            ('"', '`'),
 963            ('&', '/'),
 964            ('(', ')'),
 965            (')', '='),
 966            ('*', '('),
 967            ('/', '\''),
 968            (':', 'ª'),
 969            (';', 'º'),
 970            ('<', ';'),
 971            ('=', '*'),
 972            ('>', ':'),
 973            ('@', '"'),
 974            ('[', 'ç'),
 975            ('\'', '´'),
 976            (']', '~'),
 977            ('^', '&'),
 978            ('`', '<'),
 979            ('{', 'Ç'),
 980            ('}', '^'),
 981            ('~', '>'),
 982        ],
 983        "com.apple.keylayout.Sami-PC" => &[
 984            ('"', 'Ŋ'),
 985            ('&', '/'),
 986            ('(', ')'),
 987            (')', '='),
 988            ('*', '('),
 989            ('/', '´'),
 990            (':', 'Å'),
 991            (';', 'å'),
 992            ('<', ';'),
 993            ('=', '`'),
 994            ('>', ':'),
 995            ('@', '"'),
 996            ('Q', 'Á'),
 997            ('W', 'Š'),
 998            ('X', 'Č'),
 999            ('[', 'ø'),
1000            ('\'', 'ŋ'),
1001            ('\\', 'đ'),
1002            (']', 'æ'),
1003            ('^', '&'),
1004            ('`', 'ž'),
1005            ('q', 'á'),
1006            ('w', 'š'),
1007            ('x', 'č'),
1008            ('{', 'Ø'),
1009            ('|', 'Đ'),
1010            ('}', 'Æ'),
1011            ('~', 'Ž'),
1012        ],
1013        "com.apple.keylayout.Serbian-Latin" => &[
1014            ('"', 'Ć'),
1015            ('&', '\''),
1016            ('(', ')'),
1017            (')', '='),
1018            ('*', '('),
1019            (':', 'Č'),
1020            (';', 'č'),
1021            ('<', ';'),
1022            ('=', '*'),
1023            ('>', ':'),
1024            ('@', '"'),
1025            ('[', 'š'),
1026            ('\'', 'ć'),
1027            ('\\', 'ž'),
1028            (']', 'đ'),
1029            ('^', '&'),
1030            ('`', '<'),
1031            ('{', 'Š'),
1032            ('|', 'Ž'),
1033            ('}', 'Đ'),
1034            ('~', '>'),
1035        ],
1036        "com.apple.keylayout.Slovak" => &[
1037            ('!', '1'),
1038            ('"', '!'),
1039            ('#', '3'),
1040            ('$', '4'),
1041            ('%', '5'),
1042            ('&', '7'),
1043            ('(', '9'),
1044            (')', '0'),
1045            ('*', '8'),
1046            ('+', '%'),
1047            ('/', '\''),
1048            ('0', 'é'),
1049            ('1', '+'),
1050            ('2', 'ľ'),
1051            ('3', 'š'),
1052            ('4', 'č'),
1053            ('5', 'ť'),
1054            ('6', 'ž'),
1055            ('7', 'ý'),
1056            ('8', 'á'),
1057            ('9', 'í'),
1058            (':', '"'),
1059            (';', 'ô'),
1060            ('<', '?'),
1061            ('>', ':'),
1062            ('?', 'ˇ'),
1063            ('@', '2'),
1064            ('[', 'ú'),
1065            ('\'', '§'),
1066            (']', 'ä'),
1067            ('^', '6'),
1068            ('`', 'ň'),
1069            ('{', 'Ú'),
1070            ('}', 'Ä'),
1071            ('~', 'Ň'),
1072        ],
1073        "com.apple.keylayout.Slovak-QWERTY" => &[
1074            ('!', '1'),
1075            ('"', '!'),
1076            ('#', '3'),
1077            ('$', '4'),
1078            ('%', '5'),
1079            ('&', '7'),
1080            ('(', '9'),
1081            (')', '0'),
1082            ('*', '8'),
1083            ('+', '%'),
1084            ('/', '\''),
1085            ('0', 'é'),
1086            ('1', '+'),
1087            ('2', 'ľ'),
1088            ('3', 'š'),
1089            ('4', 'č'),
1090            ('5', 'ť'),
1091            ('6', 'ž'),
1092            ('7', 'ý'),
1093            ('8', 'á'),
1094            ('9', 'í'),
1095            (':', '"'),
1096            (';', 'ô'),
1097            ('<', '?'),
1098            ('>', ':'),
1099            ('?', 'ˇ'),
1100            ('@', '2'),
1101            ('[', 'ú'),
1102            ('\'', '§'),
1103            (']', 'ä'),
1104            ('^', '6'),
1105            ('`', 'ň'),
1106            ('{', 'Ú'),
1107            ('}', 'Ä'),
1108            ('~', 'Ň'),
1109        ],
1110        "com.apple.keylayout.Slovenian" => &[
1111            ('"', 'Ć'),
1112            ('&', '\''),
1113            ('(', ')'),
1114            (')', '='),
1115            ('*', '('),
1116            (':', 'Č'),
1117            (';', 'č'),
1118            ('<', ';'),
1119            ('=', '*'),
1120            ('>', ':'),
1121            ('@', '"'),
1122            ('[', 'š'),
1123            ('\'', 'ć'),
1124            ('\\', 'ž'),
1125            (']', 'đ'),
1126            ('^', '&'),
1127            ('`', '<'),
1128            ('{', 'Š'),
1129            ('|', 'Ž'),
1130            ('}', 'Đ'),
1131            ('~', '>'),
1132        ],
1133        "com.apple.keylayout.Spanish" => &[
1134            ('!', '¡'),
1135            ('"', '¨'),
1136            ('.', 'ç'),
1137            ('/', '.'),
1138            (':', 'º'),
1139            (';', '´'),
1140            ('<', '¿'),
1141            ('>', 'Ç'),
1142            ('@', '!'),
1143            ('[', 'ñ'),
1144            ('\'', '`'),
1145            ('\\', '\''),
1146            (']', ';'),
1147            ('^', '/'),
1148            ('`', '<'),
1149            ('{', 'Ñ'),
1150            ('|', '"'),
1151            ('}', ':'),
1152            ('~', '>'),
1153        ],
1154        "com.apple.keylayout.Spanish-ISO" => &[
1155            ('"', '¨'),
1156            ('#', '·'),
1157            ('&', '/'),
1158            ('(', ')'),
1159            (')', '='),
1160            ('*', '('),
1161            ('.', 'ç'),
1162            ('/', '.'),
1163            (':', 'º'),
1164            (';', '´'),
1165            ('<', '¿'),
1166            ('>', 'Ç'),
1167            ('@', '"'),
1168            ('[', 'ñ'),
1169            ('\'', '`'),
1170            ('\\', '\''),
1171            (']', ';'),
1172            ('^', '&'),
1173            ('`', '<'),
1174            ('{', 'Ñ'),
1175            ('|', '"'),
1176            ('}', '`'),
1177            ('~', '>'),
1178        ],
1179        "com.apple.keylayout.Swedish" => &[
1180            ('"', '^'),
1181            ('$', '€'),
1182            ('&', '/'),
1183            ('(', ')'),
1184            (')', '='),
1185            ('*', '('),
1186            ('/', '´'),
1187            (':', 'Å'),
1188            (';', 'å'),
1189            ('<', ';'),
1190            ('=', '`'),
1191            ('>', ':'),
1192            ('@', '"'),
1193            ('[', 'ö'),
1194            ('\'', '¨'),
1195            ('\\', '\''),
1196            (']', 'ä'),
1197            ('^', '&'),
1198            ('`', '<'),
1199            ('{', 'Ö'),
1200            ('|', '*'),
1201            ('}', 'Ä'),
1202            ('~', '>'),
1203        ],
1204        "com.apple.keylayout.Swedish-Pro" => &[
1205            ('"', '^'),
1206            ('$', '€'),
1207            ('&', '/'),
1208            ('(', ')'),
1209            (')', '='),
1210            ('*', '('),
1211            ('/', '´'),
1212            (':', 'Å'),
1213            (';', 'å'),
1214            ('<', ';'),
1215            ('=', '`'),
1216            ('>', ':'),
1217            ('@', '"'),
1218            ('[', 'ö'),
1219            ('\'', '¨'),
1220            ('\\', '\''),
1221            (']', 'ä'),
1222            ('^', '&'),
1223            ('`', '<'),
1224            ('{', 'Ö'),
1225            ('|', '*'),
1226            ('}', 'Ä'),
1227            ('~', '>'),
1228        ],
1229        "com.apple.keylayout.SwedishSami-PC" => &[
1230            ('"', 'ˆ'),
1231            ('&', '/'),
1232            ('(', ')'),
1233            (')', '='),
1234            ('*', '('),
1235            ('/', '´'),
1236            (':', 'Å'),
1237            (';', 'å'),
1238            ('<', ';'),
1239            ('=', '`'),
1240            ('>', ':'),
1241            ('@', '"'),
1242            ('[', 'ö'),
1243            ('\'', '¨'),
1244            ('\\', '@'),
1245            (']', 'ä'),
1246            ('^', '&'),
1247            ('`', '<'),
1248            ('{', 'Ö'),
1249            ('|', '*'),
1250            ('}', 'Ä'),
1251            ('~', '>'),
1252        ],
1253        "com.apple.keylayout.SwissFrench" => &[
1254            ('!', '+'),
1255            ('"', '`'),
1256            ('#', '*'),
1257            ('$', 'ç'),
1258            ('&', '/'),
1259            ('(', ')'),
1260            (')', '='),
1261            ('*', '('),
1262            ('+', '!'),
1263            ('/', '\''),
1264            (':', 'ü'),
1265            (';', 'è'),
1266            ('<', ';'),
1267            ('=', '¨'),
1268            ('>', ':'),
1269            ('@', '"'),
1270            ('[', 'é'),
1271            ('\'', '^'),
1272            ('\\', '$'),
1273            (']', 'à'),
1274            ('^', '&'),
1275            ('`', '<'),
1276            ('{', 'ö'),
1277            ('|', '£'),
1278            ('}', 'ä'),
1279            ('~', '>'),
1280        ],
1281        "com.apple.keylayout.SwissGerman" => &[
1282            ('!', '+'),
1283            ('"', '`'),
1284            ('#', '*'),
1285            ('$', 'ç'),
1286            ('&', '/'),
1287            ('(', ')'),
1288            (')', '='),
1289            ('*', '('),
1290            ('+', '!'),
1291            ('/', '\''),
1292            (':', 'è'),
1293            (';', 'ü'),
1294            ('<', ';'),
1295            ('=', '¨'),
1296            ('>', ':'),
1297            ('@', '"'),
1298            ('[', 'ö'),
1299            ('\'', '^'),
1300            ('\\', '$'),
1301            (']', 'ä'),
1302            ('^', '&'),
1303            ('`', '<'),
1304            ('{', 'é'),
1305            ('|', '£'),
1306            ('}', 'à'),
1307            ('~', '>'),
1308        ],
1309        "com.apple.keylayout.Turkish" => &[
1310            ('"', '-'),
1311            ('#', '"'),
1312            ('$', '\''),
1313            ('%', '('),
1314            ('&', ')'),
1315            ('(', '%'),
1316            (')', ':'),
1317            ('*', '_'),
1318            (',', 'ö'),
1319            ('-', 'ş'),
1320            ('.', 'ç'),
1321            ('/', '.'),
1322            (':', '$'),
1323            ('<', 'Ö'),
1324            ('>', 'Ç'),
1325            ('@', '*'),
1326            ('[', 'ğ'),
1327            ('\'', ','),
1328            ('\\', 'ü'),
1329            (']', 'ı'),
1330            ('^', '/'),
1331            ('_', 'Ş'),
1332            ('`', '<'),
1333            ('{', 'Ğ'),
1334            ('|', 'Ü'),
1335            ('}', 'I'),
1336            ('~', '>'),
1337        ],
1338        "com.apple.keylayout.Turkish-QWERTY-PC" => &[
1339            ('"', 'I'),
1340            ('#', '^'),
1341            ('$', '+'),
1342            ('&', '/'),
1343            ('(', ')'),
1344            (')', '='),
1345            ('*', '('),
1346            ('+', ':'),
1347            (',', 'ö'),
1348            ('.', 'ç'),
1349            ('/', '*'),
1350            (':', 'Ş'),
1351            (';', 'ş'),
1352            ('<', 'Ö'),
1353            ('=', '.'),
1354            ('>', 'Ç'),
1355            ('@', '\''),
1356            ('[', 'ğ'),
1357            ('\'', 'ı'),
1358            ('\\', ','),
1359            (']', 'ü'),
1360            ('^', '&'),
1361            ('`', '<'),
1362            ('{', 'Ğ'),
1363            ('|', ';'),
1364            ('}', 'Ü'),
1365            ('~', '>'),
1366        ],
1367        "com.apple.keylayout.Turkish-Standard" => &[
1368            ('"', 'Ş'),
1369            ('#', '^'),
1370            ('&', '\''),
1371            ('(', ')'),
1372            (')', '='),
1373            ('*', '('),
1374            (',', '.'),
1375            ('.', ','),
1376            (':', 'Ç'),
1377            (';', 'ç'),
1378            ('<', ':'),
1379            ('=', '*'),
1380            ('>', ';'),
1381            ('@', '"'),
1382            ('[', 'ğ'),
1383            ('\'', 'ş'),
1384            ('\\', 'ü'),
1385            (']', 'ı'),
1386            ('^', '&'),
1387            ('`', 'ö'),
1388            ('{', 'Ğ'),
1389            ('|', 'Ü'),
1390            ('}', 'I'),
1391            ('~', 'Ö'),
1392        ],
1393        "com.apple.keylayout.Turkmen" => &[
1394            ('C', 'Ç'),
1395            ('Q', 'Ä'),
1396            ('V', 'Ý'),
1397            ('X', 'Ü'),
1398            ('[', 'ň'),
1399            ('\\', 'ş'),
1400            (']', 'ö'),
1401            ('^', '№'),
1402            ('`', 'ž'),
1403            ('c', 'ç'),
1404            ('q', 'ä'),
1405            ('v', 'ý'),
1406            ('x', 'ü'),
1407            ('{', 'Ň'),
1408            ('|', 'Ş'),
1409            ('}', 'Ö'),
1410            ('~', 'Ž'),
1411        ],
1412        "com.apple.keylayout.USInternational-PC" => &[('^', 'ˆ'), ('~', '˜')],
1413        "com.apple.keylayout.Welsh" => &[('#', '£')],
1414
1415        _ => return None,
1416    };
1417
1418    Some(HashMap::from_iter(mappings.iter().cloned()))
1419}
1420
1421#[cfg(not(target_os = "macos"))]
1422pub fn get_key_equivalents(_layout: &str) -> Option<HashMap<char, char>> {
1423    None
1424}