1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 94 95 96 97 98 99 100 101 102 103 104 105 106 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 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 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 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 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 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 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 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 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 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 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 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 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 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 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 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 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 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 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 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 1317 1318 1319 1320 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 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
|
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PlatformKeyboardEvent.h"
#include "GtkUtilities.h"
#include "GtkVersioning.h"
#include "NotImplemented.h"
#include "WindowsKeyboardCodes.h"
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <pal/text/TextEncoding.h>
#include <wtf/HexNumber.h>
#include <wtf/text/MakeString.h>
namespace WebCore {
// FIXME: This is incomplete. We should change this to mirror
// more like what Firefox does, and generate these switch statements
// at build time.
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
String PlatformKeyboardEvent::keyValueForGdkKeyCode(unsigned keyCode)
{
switch (keyCode) {
// Modifier keys.
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
return "Alt"_s;
// Firefox uses GDK_KEY_Mode_switch for AltGraph as well.
case GDK_KEY_ISO_Level3_Shift:
case GDK_KEY_ISO_Level3_Latch:
case GDK_KEY_ISO_Level3_Lock:
case GDK_KEY_ISO_Level5_Shift:
case GDK_KEY_ISO_Level5_Latch:
case GDK_KEY_ISO_Level5_Lock:
return "AltGraph"_s;
case GDK_KEY_Caps_Lock:
return "CapsLock"_s;
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
return "Control"_s;
// Fn: This is typically a hardware key that does not generate a separate code.
// FnLock.
case GDK_KEY_Hyper_L:
case GDK_KEY_Hyper_R:
return "Hyper"_s;
case GDK_KEY_Meta_L:
case GDK_KEY_Meta_R:
return "Meta"_s;
case GDK_KEY_Num_Lock:
return "NumLock"_s;
case GDK_KEY_Scroll_Lock:
return "ScrollLock"_s;
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
return "Shift"_s;
case GDK_KEY_Super_L:
case GDK_KEY_Super_R:
return "Super"_s;
// Symbol.
// SymbolLock.
// Whitespace keys.
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_ISO_Enter:
case GDK_KEY_3270_Enter:
return "Enter"_s;
case GDK_KEY_Tab:
case GDK_KEY_KP_Tab:
return "Tab"_s;
// Navigation keys.
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
return "ArrowDown"_s;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
return "ArrowLeft"_s;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
return "ArrowRight"_s;
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
return "ArrowUp"_s;
case GDK_KEY_End:
case GDK_KEY_KP_End:
return "End"_s;
case GDK_KEY_Home:
case GDK_KEY_KP_Home:
return "Home"_s;
case GDK_KEY_Page_Down:
case GDK_KEY_KP_Page_Down:
return "PageDown"_s;
case GDK_KEY_Page_Up:
case GDK_KEY_KP_Page_Up:
return "PageUp"_s;
// Editing keys.
case GDK_KEY_BackSpace:
return "Backspace"_s;
case GDK_KEY_Clear:
return "Clear"_s;
case GDK_KEY_Copy:
return "Copy"_s;
case GDK_KEY_3270_CursorSelect:
return "CrSel"_s;
case GDK_KEY_Cut:
return "Cut"_s;
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
return "Delete"_s;
case GDK_KEY_3270_EraseEOF:
return "EraseEof"_s;
case GDK_KEY_3270_ExSelect:
return "ExSel"_s;
case GDK_KEY_Insert:
case GDK_KEY_KP_Insert:
return "Insert"_s;
case GDK_KEY_Paste:
return "Paste"_s;
case GDK_KEY_Redo:
return "Redo"_s;
case GDK_KEY_Undo:
return "Undo"_s;
// UI keys.
// Accept.
// Again.
case GDK_KEY_3270_Attn:
return "Attn"_s;
case GDK_KEY_Cancel:
return "Cancel"_s;
case GDK_KEY_Menu:
return "ContextMenu"_s;
case GDK_KEY_Escape:
return "Escape"_s;
case GDK_KEY_Execute:
return "Execute"_s;
case GDK_KEY_Find:
return "Find"_s;
case GDK_KEY_Help:
return "Help"_s;
case GDK_KEY_Pause:
case GDK_KEY_Break:
return "Pause"_s;
case GDK_KEY_3270_Play:
return "Play"_s;
// Props.
case GDK_KEY_Select:
return "Select"_s;
case GDK_KEY_ZoomIn:
return "ZoomIn"_s;
case GDK_KEY_ZoomOut:
return "ZoomOut"_s;
// Device keys.
case GDK_KEY_MonBrightnessDown:
return "BrightnessDown"_s;
case GDK_KEY_MonBrightnessUp:
return "BrightnessUp"_s;
case GDK_KEY_Eject:
return "Eject"_s;
case GDK_KEY_LogOff:
return "LogOff"_s;
// Power.
case GDK_KEY_PowerDown:
case GDK_KEY_PowerOff:
return "PowerOff"_s;
case GDK_KEY_3270_PrintScreen:
case GDK_KEY_Print:
case GDK_KEY_Sys_Req:
return "PrintScreen"_s;
case GDK_KEY_Hibernate:
return "Hibernate"_s;
case GDK_KEY_Standby:
case GDK_KEY_Suspend:
case GDK_KEY_Sleep:
return "Standby"_s;
case GDK_KEY_WakeUp:
return "WakeUp"_s;
// IME keys.
case GDK_KEY_MultipleCandidate:
return "AllCandidates"_s;
case GDK_KEY_Eisu_Shift:
case GDK_KEY_Eisu_toggle:
return "Alphanumeric"_s;
case GDK_KEY_Codeinput:
return "CodeInput"_s;
case GDK_KEY_Multi_key:
return "Compose"_s;
case GDK_KEY_Henkan:
return "Convert"_s;
case GDK_KEY_dead_grave:
case GDK_KEY_dead_acute:
case GDK_KEY_dead_circumflex:
case GDK_KEY_dead_tilde:
case GDK_KEY_dead_macron:
case GDK_KEY_dead_breve:
case GDK_KEY_dead_abovedot:
case GDK_KEY_dead_diaeresis:
case GDK_KEY_dead_abovering:
case GDK_KEY_dead_doubleacute:
case GDK_KEY_dead_caron:
case GDK_KEY_dead_cedilla:
case GDK_KEY_dead_ogonek:
case GDK_KEY_dead_iota:
case GDK_KEY_dead_voiced_sound:
case GDK_KEY_dead_semivoiced_sound:
case GDK_KEY_dead_belowdot:
case GDK_KEY_dead_hook:
case GDK_KEY_dead_horn:
case GDK_KEY_dead_stroke:
case GDK_KEY_dead_abovecomma:
case GDK_KEY_dead_abovereversedcomma:
case GDK_KEY_dead_doublegrave:
case GDK_KEY_dead_belowring:
case GDK_KEY_dead_belowmacron:
case GDK_KEY_dead_belowcircumflex:
case GDK_KEY_dead_belowtilde:
case GDK_KEY_dead_belowbreve:
case GDK_KEY_dead_belowdiaeresis:
case GDK_KEY_dead_invertedbreve:
case GDK_KEY_dead_belowcomma:
case GDK_KEY_dead_currency:
case GDK_KEY_dead_a:
case GDK_KEY_dead_A:
case GDK_KEY_dead_e:
case GDK_KEY_dead_E:
case GDK_KEY_dead_i:
case GDK_KEY_dead_I:
case GDK_KEY_dead_o:
case GDK_KEY_dead_O:
case GDK_KEY_dead_u:
case GDK_KEY_dead_U:
case GDK_KEY_dead_small_schwa:
case GDK_KEY_dead_capital_schwa:
return "Dead"_s;
// FinalMode
case GDK_KEY_ISO_First_Group:
return "GroupFirst"_s;
case GDK_KEY_ISO_Last_Group:
return "GroupLast"_s;
case GDK_KEY_ISO_Next_Group:
return "GroupNext"_s;
case GDK_KEY_ISO_Prev_Group:
return "GroupPrevious"_s;
case GDK_KEY_Mode_switch:
return "ModeChange"_s;
// NextCandidate.
case GDK_KEY_Muhenkan:
return "NonConvert"_s;
case GDK_KEY_PreviousCandidate:
return "PreviousCandidate"_s;
// Process.
case GDK_KEY_SingleCandidate:
return "SingleCandidate"_s;
// Korean and Japanese keys.
case GDK_KEY_Hangul:
return "HangulMode"_s;
case GDK_KEY_Hangul_Hanja:
return "HanjaMode"_s;
case GDK_KEY_Hangul_Jeonja:
return "JunjaMode"_s;
case GDK_KEY_Hankaku:
return "Hankaku"_s;
case GDK_KEY_Hiragana:
return "Hiragana"_s;
case GDK_KEY_Hiragana_Katakana:
return "HiraganaKatakana"_s;
case GDK_KEY_Kana_Lock:
case GDK_KEY_Kana_Shift:
return "KanaMode"_s;
case GDK_KEY_Kanji:
return "KanjiMode"_s;
case GDK_KEY_Katakana:
return "Katakana"_s;
case GDK_KEY_Romaji:
return "Romaji"_s;
case GDK_KEY_Zenkaku:
return "Zenkaku"_s;
case GDK_KEY_Zenkaku_Hankaku:
return "ZenkakuHanaku"_s;
// Application Keys
case GDK_KEY_AudioMedia:
return "LaunchMediaPlayer"_s;
// Browser Keys
case GDK_KEY_Back:
return "BrowserBack"_s;
case GDK_KEY_Favorites:
return "BrowserFavorites"_s;
case GDK_KEY_Forward:
return "BrowserForward"_s;
case GDK_KEY_HomePage:
return "BrowserHome"_s;
case GDK_KEY_Refresh:
return "BrowserRefresh"_s;
case GDK_KEY_Search:
return "BrowserSearch"_s;
case GDK_KEY_Stop:
return "BrowserStop"_s;
// ChannelDown.
// ChannelUp.
case GDK_KEY_Close:
return "Close"_s;
case GDK_KEY_MailForward:
return "MailForward"_s;
case GDK_KEY_Reply:
return "MailReply"_s;
case GDK_KEY_Send:
return "MailSend"_s;
case GDK_KEY_AudioForward:
return "MediaFastForward"_s;
case GDK_KEY_AudioPause:
return "MediaPause"_s;
case GDK_KEY_AudioPlay:
return "MediaPlay"_s;
// MediaPlayPause
case GDK_KEY_AudioRecord:
return "MediaRecord"_s;
case GDK_KEY_AudioRewind:
return "MediaRewind"_s;
case GDK_KEY_AudioStop:
return "MediaStop"_s;
case GDK_KEY_AudioNext:
return "MediaTrackNext"_s;
case GDK_KEY_AudioPrev:
return "MediaTrackPrevious"_s;
case GDK_KEY_New:
return "New"_s;
case GDK_KEY_Open:
return "Open"_s;
case GDK_KEY_AudioLowerVolume:
return "AudioVolumeDown"_s;
case GDK_KEY_AudioRaiseVolume:
return "AudioVolumeUp"_s;
case GDK_KEY_AudioMute:
return "AudioVolumeMute"_s;
// Media Controller Keys
case GDK_KEY_Red:
return "ColorF0Red"_s;
case GDK_KEY_Green:
return "ColorF1Green"_s;
case GDK_KEY_Yellow:
return "ColorF2Yellow"_s;
case GDK_KEY_Blue:
return "ColorF3Blue"_s;
case GDK_KEY_Display:
return "DisplaySwap"_s;
case GDK_KEY_Video:
return "OnDemand"_s;
case GDK_KEY_Subtitle:
return "Subtitle"_s;
// Print.
case GDK_KEY_Save:
return "Save"_s;
case GDK_KEY_Spell:
return "SpellCheck"_s;
// Function keys.
case GDK_KEY_F1:
return "F1"_s;
case GDK_KEY_F2:
return "F2"_s;
case GDK_KEY_F3:
return "F3"_s;
case GDK_KEY_F4:
return "F4"_s;
case GDK_KEY_F5:
return "F5"_s;
case GDK_KEY_F6:
return "F6"_s;
case GDK_KEY_F7:
return "F7"_s;
case GDK_KEY_F8:
return "F8"_s;
case GDK_KEY_F9:
return "F9"_s;
case GDK_KEY_F10:
return "F10"_s;
case GDK_KEY_F11:
return "F11"_s;
case GDK_KEY_F12:
return "F12"_s;
case GDK_KEY_F13:
return "F13"_s;
case GDK_KEY_F14:
return "F14"_s;
case GDK_KEY_F15:
return "F15"_s;
case GDK_KEY_F16:
return "F16"_s;
case GDK_KEY_F17:
return "F17"_s;
case GDK_KEY_F18:
return "F18"_s;
case GDK_KEY_F19:
return "F19"_s;
case GDK_KEY_F20:
return "F20"_s;
default: {
guint32 unicodeCharacter = gdk_keyval_to_unicode(keyCode);
if (unicodeCharacter) {
// UTF-8 will use up to 6 bytes.
char utf8[7] = { 0 };
g_unichar_to_utf8(unicodeCharacter, utf8);
return String::fromUTF8(utf8);
}
return "Unidentified"_s;
}
}
}
// FIXME: This is incomplete. We should change this to mirror
// more like what Firefox does, and generate these switch statements
// at build time.
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
String PlatformKeyboardEvent::keyCodeForHardwareKeyCode(unsigned keyCode)
{
switch (keyCode) {
case 0x0009:
return "Escape"_s;
case 0x000A:
return "Digit1"_s;
case 0x000B:
return "Digit2"_s;
case 0x000C:
return "Digit3"_s;
case 0x000D:
return "Digit4"_s;
case 0x000E:
return "Digit5"_s;
case 0x000F:
return "Digit6"_s;
case 0x0010:
return "Digit7"_s;
case 0x0011:
return "Digit8"_s;
case 0x0012:
return "Digit9"_s;
case 0x0013:
return "Digit0"_s;
case 0x0014:
return "Minus"_s;
case 0x0015:
return "Equal"_s;
case 0x0016:
return "Backspace"_s;
case 0x0017:
return "Tab"_s;
case 0x0018:
return "KeyQ"_s;
case 0x0019:
return "KeyW"_s;
case 0x001A:
return "KeyE"_s;
case 0x001B:
return "KeyR"_s;
case 0x001C:
return "KeyT"_s;
case 0x001D:
return "KeyY"_s;
case 0x001E:
return "KeyU"_s;
case 0x001F:
return "KeyI"_s;
case 0x0020:
return "KeyO"_s;
case 0x0021:
return "KeyP"_s;
case 0x0022:
return "BracketLeft"_s;
case 0x0023:
return "BracketRight"_s;
case 0x0024:
return "Enter"_s;
case 0x0025:
return "ControlLeft"_s;
case 0x0026:
return "KeyA"_s;
case 0x0027:
return "KeyS"_s;
case 0x0028:
return "KeyD"_s;
case 0x0029:
return "KeyF"_s;
case 0x002A:
return "KeyG"_s;
case 0x002B:
return "KeyH"_s;
case 0x002C:
return "KeyJ"_s;
case 0x002D:
return "KeyK"_s;
case 0x002E:
return "KeyL"_s;
case 0x002F:
return "Semicolon"_s;
case 0x0030:
return "Quote"_s;
case 0x0031:
return "Backquote"_s;
case 0x0032:
return "ShiftLeft"_s;
case 0x0033:
return "Backslash"_s;
case 0x0034:
return "KeyZ"_s;
case 0x0035:
return "KeyX"_s;
case 0x0036:
return "KeyC"_s;
case 0x0037:
return "KeyV"_s;
case 0x0038:
return "KeyB"_s;
case 0x0039:
return "KeyN"_s;
case 0x003A:
return "KeyM"_s;
case 0x003B:
return "Comma"_s;
case 0x003C:
return "Period"_s;
case 0x003D:
return "Slash"_s;
case 0x003E:
return "ShiftRight"_s;
case 0x003F:
return "NumpadMultiply"_s;
case 0x0040:
return "AltLeft"_s;
case 0x0041:
return "Space"_s;
case 0x0042:
return "CapsLock"_s;
case 0x0043:
return "F1"_s;
case 0x0044:
return "F2"_s;
case 0x0045:
return "F3"_s;
case 0x0046:
return "F4"_s;
case 0x0047:
return "F5"_s;
case 0x0048:
return "F6"_s;
case 0x0049:
return "F7"_s;
case 0x004A:
return "F8"_s;
case 0x004B:
return "F9"_s;
case 0x004C:
return "F10"_s;
case 0x004D:
return "NumLock"_s;
case 0x004E:
return "ScrollLock"_s;
case 0x004F:
return "Numpad7"_s;
case 0x0050:
return "Numpad8"_s;
case 0x0051:
return "Numpad9"_s;
case 0x0052:
return "NumpadSubtract"_s;
case 0x0053:
return "Numpad4"_s;
case 0x0054:
return "Numpad5"_s;
case 0x0055:
return "Numpad6"_s;
case 0x0056:
return "NumpadAdd"_s;
case 0x0057:
return "Numpad1"_s;
case 0x0058:
return "Numpad2"_s;
case 0x0059:
return "Numpad3"_s;
case 0x005A:
return "Numpad0"_s;
case 0x005B:
return "NumpadDecimal"_s;
case 0x005E:
return "IntlBackslash"_s;
case 0x005F:
return "F11"_s;
case 0x0060:
return "F12"_s;
case 0x0061:
return "IntlRo"_s;
case 0x0064:
return "Convert"_s;
case 0x0065:
return "KanaMode"_s;
case 0x0066:
return "NonConvert"_s;
case 0x0068:
return "NumpadEnter"_s;
case 0x0069:
return "ControlRight"_s;
case 0x006A:
return "NumpadDivide"_s;
case 0x006B:
return "PrintScreen"_s;
case 0x006C:
return "AltRight"_s;
case 0x006E:
return "Home"_s;
case 0x006F:
return "ArrowUp"_s;
case 0x0070:
return "PageUp"_s;
case 0x0071:
return "ArrowLeft"_s;
case 0x0072:
return "ArrowRight"_s;
case 0x0073:
return "End"_s;
case 0x0074:
return "ArrowDown"_s;
case 0x0075:
return "PageDown"_s;
case 0x0076:
return "Insert"_s;
case 0x0077:
return "Delete"_s;
case 0x0079:
return "AudioVolumeMute"_s;
case 0x007A:
return "AudioVolumeDown"_s;
case 0x007B:
return "AudioVolumeUp"_s;
case 0x007D:
return "NumpadEqual"_s;
case 0x007F:
return "Pause"_s;
case 0x0081:
return "NumpadComma"_s;
case 0x0082:
return "Lang1"_s;
case 0x0083:
return "Lang2"_s;
case 0x0084:
return "IntlYen"_s;
case 0x0085:
return "OSLeft"_s;
case 0x0086:
return "OSRight"_s;
case 0x0087:
return "ContextMenu"_s;
case 0x0088:
return "BrowserStop"_s;
case 0x0089:
return "Again"_s;
case 0x008A:
return "Props"_s;
case 0x008B:
return "Undo"_s;
case 0x008C:
return "Select"_s;
case 0x008D:
return "Copy"_s;
case 0x008E:
return "Open"_s;
case 0x008F:
return "Paste"_s;
case 0x0090:
return "Find"_s;
case 0x0091:
return "Cut"_s;
case 0x0092:
return "Help"_s;
case 0x0094:
return "LaunchApp2"_s;
case 0x0097:
return "WakeUp"_s;
case 0x0098:
return "LaunchApp1"_s;
case 0x00A3:
return "LaunchMail"_s;
case 0x00A4:
return "BrowserFavorites"_s;
case 0x00A6:
return "BrowserBack"_s;
case 0x00A7:
return "BrowserForward"_s;
case 0x00A9:
return "Eject"_s;
case 0x00AB:
return "MediaTrackNext"_s;
case 0x00AC:
return "MediaPlayPause"_s;
case 0x00AD:
return "MediaTrackPrevious"_s;
case 0x00AE:
return "MediaStop"_s;
case 0x00B3:
return "LaunchMediaPlayer"_s;
case 0x00B4:
return "BrowserHome"_s;
case 0x00B5:
return "BrowserRefresh"_s;
case 0x00BF:
return "F13"_s;
case 0x00C0:
return "F14"_s;
case 0x00C1:
return "F15"_s;
case 0x00C2:
return "F16"_s;
case 0x00C3:
return "F17"_s;
case 0x00C4:
return "F18"_s;
case 0x00C5:
return "F19"_s;
case 0x00C6:
return "F20"_s;
case 0x00C7:
return "F21"_s;
case 0x00C8:
return "F22"_s;
case 0x00C9:
return "F23"_s;
case 0x00CA:
return "F24"_s;
case 0x00E1:
return "BrowserSearch"_s;
default:
return "Unidentified"_s;
}
}
// FIXME: This is incomplete. We should change this to mirror
// more like what Firefox does, and generate these switch statements
// at build time.
String PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(unsigned keyCode)
{
switch (keyCode) {
case GDK_KEY_Menu:
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
return "Alt"_s;
case GDK_KEY_Clear:
return "Clear"_s;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
return "Down"_s;
// "End"
case GDK_KEY_End:
case GDK_KEY_KP_End:
return "End"_s;
// "Enter"
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_Return:
return "Enter"_s;
case GDK_KEY_Execute:
return "Execute"_s;
case GDK_KEY_F1:
return "F1"_s;
case GDK_KEY_F2:
return "F2"_s;
case GDK_KEY_F3:
return "F3"_s;
case GDK_KEY_F4:
return "F4"_s;
case GDK_KEY_F5:
return "F5"_s;
case GDK_KEY_F6:
return "F6"_s;
case GDK_KEY_F7:
return "F7"_s;
case GDK_KEY_F8:
return "F8"_s;
case GDK_KEY_F9:
return "F9"_s;
case GDK_KEY_F10:
return "F10"_s;
case GDK_KEY_F11:
return "F11"_s;
case GDK_KEY_F12:
return "F12"_s;
case GDK_KEY_F13:
return "F13"_s;
case GDK_KEY_F14:
return "F14"_s;
case GDK_KEY_F15:
return "F15"_s;
case GDK_KEY_F16:
return "F16"_s;
case GDK_KEY_F17:
return "F17"_s;
case GDK_KEY_F18:
return "F18"_s;
case GDK_KEY_F19:
return "F19"_s;
case GDK_KEY_F20:
return "F20"_s;
case GDK_KEY_F21:
return "F21"_s;
case GDK_KEY_F22:
return "F22"_s;
case GDK_KEY_F23:
return "F23"_s;
case GDK_KEY_F24:
return "F24"_s;
case GDK_KEY_Help:
return "Help"_s;
case GDK_KEY_Home:
case GDK_KEY_KP_Home:
return "Home"_s;
case GDK_KEY_Insert:
return "Insert"_s;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
return "Left"_s;
case GDK_KEY_Page_Down:
case GDK_KEY_KP_Page_Down:
return "PageDown"_s;
case GDK_KEY_Page_Up:
case GDK_KEY_KP_Page_Up:
return "PageUp"_s;
case GDK_KEY_Pause:
return "Pause"_s;
case GDK_KEY_3270_PrintScreen:
case GDK_KEY_Print:
return "PrintScreen"_s;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
return "Right"_s;
case GDK_KEY_Select:
return "Select"_s;
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
return "Up"_s;
// Standard says that DEL becomes U+007F.
case GDK_KEY_Delete:
return "U+007F"_s;
case GDK_KEY_BackSpace:
return "U+0008"_s;
case GDK_KEY_ISO_Left_Tab:
case GDK_KEY_3270_BackTab:
case GDK_KEY_Tab:
return "U+0009"_s;
default:
return makeString("U+"_s, hex(gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)), 4));
}
}
int PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(unsigned keycode)
{
switch (keycode) {
case GDK_KEY_Cancel:
return 0x03; // (03) The Cancel key
case GDK_KEY_KP_0:
return VK_NUMPAD0; // (60) Numeric keypad 0 key
case GDK_KEY_KP_1:
return VK_NUMPAD1; // (61) Numeric keypad 1 key
case GDK_KEY_KP_2:
return VK_NUMPAD2; // (62) Numeric keypad 2 key
case GDK_KEY_KP_3:
return VK_NUMPAD3; // (63) Numeric keypad 3 key
case GDK_KEY_KP_4:
return VK_NUMPAD4; // (64) Numeric keypad 4 key
case GDK_KEY_KP_5:
return VK_NUMPAD5; // (65) Numeric keypad 5 key
case GDK_KEY_KP_6:
return VK_NUMPAD6; // (66) Numeric keypad 6 key
case GDK_KEY_KP_7:
return VK_NUMPAD7; // (67) Numeric keypad 7 key
case GDK_KEY_KP_8:
return VK_NUMPAD8; // (68) Numeric keypad 8 key
case GDK_KEY_KP_9:
return VK_NUMPAD9; // (69) Numeric keypad 9 key
case GDK_KEY_KP_Multiply:
return VK_MULTIPLY; // (6A) Multiply key
case GDK_KEY_KP_Add:
return VK_ADD; // (6B) Add key
case GDK_KEY_KP_Subtract:
return VK_SUBTRACT; // (6D) Subtract key
case GDK_KEY_KP_Decimal:
return VK_DECIMAL; // (6E) Decimal key
case GDK_KEY_KP_Divide:
return VK_DIVIDE; // (6F) Divide key
case GDK_KEY_KP_Page_Up:
return VK_PRIOR; // (21) PAGE UP key
case GDK_KEY_KP_Page_Down:
return VK_NEXT; // (22) PAGE DOWN key
case GDK_KEY_KP_End:
return VK_END; // (23) END key
case GDK_KEY_KP_Home:
return VK_HOME; // (24) HOME key
case GDK_KEY_KP_Left:
return VK_LEFT; // (25) LEFT ARROW key
case GDK_KEY_KP_Up:
return VK_UP; // (26) UP ARROW key
case GDK_KEY_KP_Right:
return VK_RIGHT; // (27) RIGHT ARROW key
case GDK_KEY_KP_Down:
return VK_DOWN; // (28) DOWN ARROW key
case GDK_KEY_BackSpace:
return VK_BACK; // (08) BACKSPACE key
case GDK_KEY_ISO_Left_Tab:
case GDK_KEY_3270_BackTab:
case GDK_KEY_Tab:
return VK_TAB; // (09) TAB key
case GDK_KEY_Clear:
return VK_CLEAR; // (0C) CLEAR key
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_Return:
return VK_RETURN; // (0D) Return key
// VK_SHIFT (10) SHIFT key
// VK_CONTROL (11) CTRL key
case GDK_KEY_Menu:
return VK_APPS; // (5D) Applications key (Natural keyboard)
// VK_MENU (12) ALT key
case GDK_KEY_Pause:
case GDK_KEY_AudioPause:
return VK_PAUSE; // (13) PAUSE key
case GDK_KEY_Caps_Lock:
return VK_CAPITAL; // (14) CAPS LOCK key
case GDK_KEY_Kana_Lock:
case GDK_KEY_Kana_Shift:
return VK_KANA; // (15) Input Method Editor (IME) Kana mode
case GDK_KEY_Hangul:
return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode
// VK_JUNJA (17) IME Junja mode
// VK_FINAL (18) IME final mode
case GDK_KEY_Hangul_Hanja:
return VK_HANJA; // (19) IME Hanja mode
case GDK_KEY_Kanji:
return VK_KANJI; // (19) IME Kanji mode
case GDK_KEY_Escape:
return VK_ESCAPE; // (1B) ESC key
// VK_CONVERT (1C) IME convert
// VK_NONCONVERT (1D) IME nonconvert
// VK_ACCEPT (1E) IME accept
// VK_MODECHANGE (1F) IME mode change request
case GDK_KEY_space:
return VK_SPACE; // (20) SPACEBAR
case GDK_KEY_Page_Up:
return VK_PRIOR; // (21) PAGE UP key
case GDK_KEY_Page_Down:
return VK_NEXT; // (22) PAGE DOWN key
case GDK_KEY_End:
return VK_END; // (23) END key
case GDK_KEY_Home:
return VK_HOME; // (24) HOME key
case GDK_KEY_Left:
return VK_LEFT; // (25) LEFT ARROW key
case GDK_KEY_Up:
return VK_UP; // (26) UP ARROW key
case GDK_KEY_Right:
return VK_RIGHT; // (27) RIGHT ARROW key
case GDK_KEY_Down:
return VK_DOWN; // (28) DOWN ARROW key
case GDK_KEY_Select:
return VK_SELECT; // (29) SELECT key
case GDK_KEY_Print:
return VK_SNAPSHOT; // (2C) PRINT SCREEN key
case GDK_KEY_Execute:
return VK_EXECUTE; // (2B) EXECUTE key
case GDK_KEY_Insert:
case GDK_KEY_KP_Insert:
return VK_INSERT; // (2D) INS key
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
return VK_DELETE; // (2E) DEL key
case GDK_KEY_Help:
return VK_HELP; // (2F) HELP key
case GDK_KEY_0:
case GDK_KEY_parenright:
return VK_0; // (30) 0) key
case GDK_KEY_1:
case GDK_KEY_exclam:
return VK_1; // (31) 1 ! key
case GDK_KEY_2:
case GDK_KEY_at:
return VK_2; // (32) 2 & key
case GDK_KEY_3:
case GDK_KEY_numbersign:
return VK_3; // case '3': case '#';
case GDK_KEY_4:
case GDK_KEY_dollar: // (34) 4 key '$';
return VK_4;
case GDK_KEY_5:
case GDK_KEY_percent:
return VK_5; // (35) 5 key '%'
case GDK_KEY_6:
case GDK_KEY_asciicircum:
return VK_6; // (36) 6 key '^'
case GDK_KEY_7:
case GDK_KEY_ampersand:
return VK_7; // (37) 7 key case '&'
case GDK_KEY_8:
case GDK_KEY_asterisk:
return VK_8; // (38) 8 key '*'
case GDK_KEY_9:
case GDK_KEY_parenleft:
return VK_9; // (39) 9 key '('
case GDK_KEY_a:
case GDK_KEY_A:
return VK_A; // (41) A key case 'a': case 'A': return 0x41;
case GDK_KEY_b:
case GDK_KEY_B:
return VK_B; // (42) B key case 'b': case 'B': return 0x42;
case GDK_KEY_c:
case GDK_KEY_C:
return VK_C; // (43) C key case 'c': case 'C': return 0x43;
case GDK_KEY_d:
case GDK_KEY_D:
return VK_D; // (44) D key case 'd': case 'D': return 0x44;
case GDK_KEY_e:
case GDK_KEY_E:
return VK_E; // (45) E key case 'e': case 'E': return 0x45;
case GDK_KEY_f:
case GDK_KEY_F:
return VK_F; // (46) F key case 'f': case 'F': return 0x46;
case GDK_KEY_g:
case GDK_KEY_G:
return VK_G; // (47) G key case 'g': case 'G': return 0x47;
case GDK_KEY_h:
case GDK_KEY_H:
return VK_H; // (48) H key case 'h': case 'H': return 0x48;
case GDK_KEY_i:
case GDK_KEY_I:
return VK_I; // (49) I key case 'i': case 'I': return 0x49;
case GDK_KEY_j:
case GDK_KEY_J:
return VK_J; // (4A) J key case 'j': case 'J': return 0x4A;
case GDK_KEY_k:
case GDK_KEY_K:
return VK_K; // (4B) K key case 'k': case 'K': return 0x4B;
case GDK_KEY_l:
case GDK_KEY_L:
return VK_L; // (4C) L key case 'l': case 'L': return 0x4C;
case GDK_KEY_m:
case GDK_KEY_M:
return VK_M; // (4D) M key case 'm': case 'M': return 0x4D;
case GDK_KEY_n:
case GDK_KEY_N:
return VK_N; // (4E) N key case 'n': case 'N': return 0x4E;
case GDK_KEY_o:
case GDK_KEY_O:
return VK_O; // (4F) O key case 'o': case 'O': return 0x4F;
case GDK_KEY_p:
case GDK_KEY_P:
return VK_P; // (50) P key case 'p': case 'P': return 0x50;
case GDK_KEY_q:
case GDK_KEY_Q:
return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51;
case GDK_KEY_r:
case GDK_KEY_R:
return VK_R; // (52) R key case 'r': case 'R': return 0x52;
case GDK_KEY_s:
case GDK_KEY_S:
return VK_S; // (53) S key case 's': case 'S': return 0x53;
case GDK_KEY_t:
case GDK_KEY_T:
return VK_T; // (54) T key case 't': case 'T': return 0x54;
case GDK_KEY_u:
case GDK_KEY_U:
return VK_U; // (55) U key case 'u': case 'U': return 0x55;
case GDK_KEY_v:
case GDK_KEY_V:
return VK_V; // (56) V key case 'v': case 'V': return 0x56;
case GDK_KEY_w:
case GDK_KEY_W:
return VK_W; // (57) W key case 'w': case 'W': return 0x57;
case GDK_KEY_x:
case GDK_KEY_X:
return VK_X; // (58) X key case 'x': case 'X': return 0x58;
case GDK_KEY_y:
case GDK_KEY_Y:
return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59;
case GDK_KEY_z:
case GDK_KEY_Z:
return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
case GDK_KEY_Meta_L:
return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
case GDK_KEY_Meta_R:
return VK_RWIN; // (5C) Right Windows key (Natural keyboard)
case GDK_KEY_Sleep:
return VK_SLEEP; // (5F) Computer Sleep key
// VK_SEPARATOR (6C) Separator key
// VK_SUBTRACT (6D) Subtract key
// VK_DECIMAL (6E) Decimal key
// VK_DIVIDE (6F) Divide key
// handled by key code above
case GDK_KEY_Num_Lock:
return VK_NUMLOCK; // (90) NUM LOCK key
case GDK_KEY_Scroll_Lock:
return VK_SCROLL; // (91) SCROLL LOCK key
case GDK_KEY_Shift_L:
return VK_LSHIFT; // (A0) Left SHIFT key
case GDK_KEY_Shift_R:
return VK_RSHIFT; // (A1) Right SHIFT key
case GDK_KEY_Control_L:
return VK_LCONTROL; // (A2) Left CONTROL key
case GDK_KEY_Control_R:
return VK_RCONTROL; // (A3) Right CONTROL key
case GDK_KEY_Alt_L:
return VK_LMENU; // (A4) Left MENU key
case GDK_KEY_Alt_R:
return VK_RMENU; // (A5) Right MENU key
case GDK_KEY_Back:
return VK_BROWSER_BACK; // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
case GDK_KEY_Forward:
return VK_BROWSER_FORWARD; // (A7) Windows 2000/XP: Browser Forward key
case GDK_KEY_Refresh:
return VK_BROWSER_REFRESH; // (A8) Windows 2000/XP: Browser Refresh key
case GDK_KEY_Stop:
return VK_BROWSER_STOP; // (A9) Windows 2000/XP: Browser Stop key
case GDK_KEY_Search:
return VK_BROWSER_SEARCH; // (AA) Windows 2000/XP: Browser Search key
case GDK_KEY_Favorites:
return VK_BROWSER_FAVORITES; // (AB) Windows 2000/XP: Browser Favorites key
case GDK_KEY_HomePage:
return VK_BROWSER_HOME; // (AC) Windows 2000/XP: Browser Start and Home key
case GDK_KEY_AudioMute:
return VK_VOLUME_MUTE; // (AD) Windows 2000/XP: Volume Mute key
case GDK_KEY_AudioLowerVolume:
return VK_VOLUME_DOWN; // (AE) Windows 2000/XP: Volume Down key
case GDK_KEY_AudioRaiseVolume:
return VK_VOLUME_UP; // (AF) Windows 2000/XP: Volume Up key
case GDK_KEY_AudioNext:
return VK_MEDIA_NEXT_TRACK; // (B0) Windows 2000/XP: Next Track key
case GDK_KEY_AudioPrev:
return VK_MEDIA_PREV_TRACK; // (B1) Windows 2000/XP: Previous Track key
case GDK_KEY_AudioStop:
return VK_MEDIA_STOP; // (B2) Windows 2000/XP: Stop Media key
// VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
// VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
case GDK_KEY_AudioMedia:
return VK_MEDIA_LAUNCH_MEDIA_SELECT; // (B5) Windows 2000/XP: Select Media key
// VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
// VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
// VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
case GDK_KEY_semicolon:
case GDK_KEY_colon:
return VK_OEM_1; // case ';': case ':': return 0xBA;
// VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
case GDK_KEY_plus:
case GDK_KEY_equal:
return VK_OEM_PLUS; // case '=': case '+': return 0xBB;
// VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
case GDK_KEY_comma:
case GDK_KEY_less:
return VK_OEM_COMMA; // case ',': case '<': return 0xBC;
// VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
case GDK_KEY_minus:
case GDK_KEY_underscore:
return VK_OEM_MINUS; // case '-': case '_': return 0xBD;
// VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
case GDK_KEY_period:
case GDK_KEY_greater:
return VK_OEM_PERIOD; // case '.': case '>': return 0xBE;
// VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
case GDK_KEY_slash:
case GDK_KEY_question:
return VK_OEM_2; // case '/': case '?': return 0xBF;
// VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
case GDK_KEY_asciitilde:
case GDK_KEY_quoteleft:
return VK_OEM_3; // case '`': case '~': return 0xC0;
// VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
case GDK_KEY_bracketleft:
case GDK_KEY_braceleft:
return VK_OEM_4; // case '[': case '{': return 0xDB;
// VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
case GDK_KEY_backslash:
case GDK_KEY_bar:
return VK_OEM_5; // case '\\': case '|': return 0xDC;
// VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
case GDK_KEY_bracketright:
case GDK_KEY_braceright:
return VK_OEM_6; // case ']': case '}': return 0xDD;
// VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
case GDK_KEY_quoteright:
case GDK_KEY_quotedbl:
return VK_OEM_7; // case '\'': case '"': return 0xDE;
// VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
// VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
case GDK_KEY_AudioRewind:
return 0xE3; // (E3) Android/GoogleTV: Rewind media key (Windows: VK_ICO_HELP Help key on 1984 Olivetti M24 deluxe keyboard)
case GDK_KEY_AudioForward:
return 0xE4; // (E4) Android/GoogleTV: Fast forward media key (Windows: VK_ICO_00 '00' key on 1984 Olivetti M24 deluxe keyboard)
// VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
// VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
// VK_ATTN (F6) Attn key
// VK_CRSEL (F7) CrSel key
// VK_EXSEL (F8) ExSel key
// VK_EREOF (F9) Erase EOF key
case GDK_KEY_AudioPlay:
return VK_PLAY; // VK_PLAY (FA) Play key
// VK_ZOOM (FB) Zoom key
// VK_NONAME (FC) Reserved for future use
// VK_PA1 (FD) PA1 key
// VK_OEM_CLEAR (FE) Clear key
case GDK_KEY_F1:
case GDK_KEY_F2:
case GDK_KEY_F3:
case GDK_KEY_F4:
case GDK_KEY_F5:
case GDK_KEY_F6:
case GDK_KEY_F7:
case GDK_KEY_F8:
case GDK_KEY_F9:
case GDK_KEY_F10:
case GDK_KEY_F11:
case GDK_KEY_F12:
case GDK_KEY_F13:
case GDK_KEY_F14:
case GDK_KEY_F15:
case GDK_KEY_F16:
case GDK_KEY_F17:
case GDK_KEY_F18:
case GDK_KEY_F19:
case GDK_KEY_F20:
case GDK_KEY_F21:
case GDK_KEY_F22:
case GDK_KEY_F23:
case GDK_KEY_F24:
return VK_F1 + (keycode - GDK_KEY_F1);
case GDK_KEY_VoidSymbol:
return VK_PROCESSKEY;
// TV keycodes from DASE / OCAP / CE-HTML standards.
case GDK_KEY_Red:
return 0x193; // General purpose color-coded media function key, as index 0 (red)
case GDK_KEY_Green:
return 0x194; // General purpose color-coded media function key, as index 1 (green)
case GDK_KEY_Yellow:
return 0x195; // General purpose color-coded media function key, as index 2 (yellow)
case GDK_KEY_Blue:
return 0x196; // General purpose color-coded media function key, as index 3 (blue)
case GDK_KEY_PowerOff:
return 0x199; // Toggle power state
case GDK_KEY_AudioRecord:
return 0x1A0; // Initiate or resume recording of currently selected media
case GDK_KEY_Display:
return 0x1BC; // Swap video sources
case GDK_KEY_Subtitle:
return 0x1CC; // Toggle display of subtitles, if available
case GDK_KEY_Video:
return 0x26F; // Access on-demand content or programs
default:
return 0;
}
}
String PlatformKeyboardEvent::singleCharacterString(unsigned val)
{
switch (val) {
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_Return:
return String("\r"_s);
case GDK_KEY_BackSpace:
return String("\x8"_s);
case GDK_KEY_Tab:
return String("\t"_s);
default:
gunichar c = gdk_keyval_to_unicode(val);
glong nwc;
gunichar2* uchar16 = g_ucs4_to_utf16(&c, 1, 0, &nwc, 0);
String retVal;
if (uchar16)
retVal = String(unsafeMakeSpan((UChar*)uchar16, static_cast<size_t>(nwc)));
else
retVal = String();
g_free(uchar16);
return retVal;
}
}
void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
{
// Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
ASSERT(m_type == PlatformEvent::Type::KeyDown);
m_type = type;
if (backwardCompatibilityMode || m_handledByInputMethod)
return;
if (type == PlatformEvent::Type::RawKeyDown) {
m_text = String();
m_unmodifiedText = String();
} else {
m_keyIdentifier = String();
m_windowsVirtualKeyCode = 0;
}
}
OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
{
if (s_currentModifiers)
return *s_currentModifiers;
return { };
}
}
|