Unverified Commit a7899c19 authored by Tong Mu's avatar Tong Mu Committed by GitHub

[gen_keycodes] Remove nonexistent Web keys and improve their emulation (#87098)

parent c451b6b0
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
"value": 32, "value": 32,
"keyLabel": " ", "keyLabel": " ",
"names": { "names": {
"web": [
"Space"
],
"gtk": [ "gtk": [
"KP_Space" "KP_Space"
], ],
...@@ -41,21 +38,13 @@ ...@@ -41,21 +38,13 @@
"Exclamation": { "Exclamation": {
"name": "Exclamation", "name": "Exclamation",
"value": 33, "value": 33,
"keyLabel": "!", "keyLabel": "!"
"names": {
"web": [
"Exclamation"
]
}
}, },
"Quote": { "Quote": {
"name": "Quote", "name": "Quote",
"value": 34, "value": 34,
"keyLabel": "\"", "keyLabel": "\"",
"names": { "names": {
"web": [
"Quote"
],
"windows": [ "windows": [
"OEM_7" "OEM_7"
], ],
...@@ -86,9 +75,6 @@ ...@@ -86,9 +75,6 @@
"value": 35, "value": 35,
"keyLabel": "#", "keyLabel": "#",
"names": { "names": {
"web": [
"NumberSign"
],
"android": [ "android": [
"POUND" "POUND"
] ]
...@@ -102,71 +88,38 @@ ...@@ -102,71 +88,38 @@
"Dollar": { "Dollar": {
"name": "Dollar", "name": "Dollar",
"value": 36, "value": 36,
"keyLabel": "$", "keyLabel": "$"
"names": {
"web": [
"Dollar"
]
}
}, },
"Percent": { "Percent": {
"name": "Percent", "name": "Percent",
"value": 37, "value": 37,
"keyLabel": "%", "keyLabel": "%"
"names": {
"web": [
"Percent"
]
}
}, },
"Ampersand": { "Ampersand": {
"name": "Ampersand", "name": "Ampersand",
"value": 38, "value": 38,
"keyLabel": "&", "keyLabel": "&"
"names": {
"web": [
"Ampersand"
]
}
}, },
"QuoteSingle": { "QuoteSingle": {
"name": "QuoteSingle", "name": "QuoteSingle",
"value": 39, "value": 39,
"keyLabel": "'", "keyLabel": "'"
"names": {
"web": [
"QuoteSingle"
]
}
}, },
"ParenthesisLeft": { "ParenthesisLeft": {
"name": "ParenthesisLeft", "name": "ParenthesisLeft",
"value": 40, "value": 40,
"keyLabel": "(", "keyLabel": "("
"names": {
"web": [
"ParenthesisLeft"
]
}
}, },
"ParenthesisRight": { "ParenthesisRight": {
"name": "ParenthesisRight", "name": "ParenthesisRight",
"value": 41, "value": 41,
"keyLabel": ")", "keyLabel": ")"
"names": {
"web": [
"ParenthesisRight"
]
}
}, },
"Asterisk": { "Asterisk": {
"name": "Asterisk", "name": "Asterisk",
"value": 42, "value": 42,
"keyLabel": "*", "keyLabel": "*",
"names": { "names": {
"web": [
"Asterisk"
],
"android": [ "android": [
"STAR" "STAR"
] ]
...@@ -182,9 +135,6 @@ ...@@ -182,9 +135,6 @@
"value": 43, "value": 43,
"keyLabel": "+", "keyLabel": "+",
"names": { "names": {
"web": [
"Add"
],
"android": [ "android": [
"PLUS" "PLUS"
] ]
...@@ -200,9 +150,6 @@ ...@@ -200,9 +150,6 @@
"value": 44, "value": 44,
"keyLabel": ",", "keyLabel": ",",
"names": { "names": {
"web": [
"Comma"
],
"windows": [ "windows": [
"OEM_COMMA" "OEM_COMMA"
], ],
...@@ -233,9 +180,6 @@ ...@@ -233,9 +180,6 @@
"value": 45, "value": 45,
"keyLabel": "-", "keyLabel": "-",
"names": { "names": {
"web": [
"Minus"
],
"windows": [ "windows": [
"OEM_MINUS" "OEM_MINUS"
], ],
...@@ -266,9 +210,6 @@ ...@@ -266,9 +210,6 @@
"value": 46, "value": 46,
"keyLabel": ".", "keyLabel": ".",
"names": { "names": {
"web": [
"Period"
],
"gtk": [ "gtk": [
"KP_Decimal" "KP_Decimal"
], ],
...@@ -305,9 +246,6 @@ ...@@ -305,9 +246,6 @@
"value": 47, "value": 47,
"keyLabel": "/", "keyLabel": "/",
"names": { "names": {
"web": [
"Slash"
],
"windows": [ "windows": [
"OEM_2" "OEM_2"
], ],
...@@ -338,9 +276,6 @@ ...@@ -338,9 +276,6 @@
"value": 48, "value": 48,
"keyLabel": "0", "keyLabel": "0",
"names": { "names": {
"web": [
"Digit0"
],
"android": [ "android": [
"0" "0"
], ],
...@@ -365,9 +300,6 @@ ...@@ -365,9 +300,6 @@
"value": 49, "value": 49,
"keyLabel": "1", "keyLabel": "1",
"names": { "names": {
"web": [
"Digit1"
],
"android": [ "android": [
"1" "1"
], ],
...@@ -392,9 +324,6 @@ ...@@ -392,9 +324,6 @@
"value": 50, "value": 50,
"keyLabel": "2", "keyLabel": "2",
"names": { "names": {
"web": [
"Digit2"
],
"android": [ "android": [
"2" "2"
], ],
...@@ -419,9 +348,6 @@ ...@@ -419,9 +348,6 @@
"value": 51, "value": 51,
"keyLabel": "3", "keyLabel": "3",
"names": { "names": {
"web": [
"Digit3"
],
"android": [ "android": [
"3" "3"
], ],
...@@ -446,9 +372,6 @@ ...@@ -446,9 +372,6 @@
"value": 52, "value": 52,
"keyLabel": "4", "keyLabel": "4",
"names": { "names": {
"web": [
"Digit4"
],
"android": [ "android": [
"4" "4"
], ],
...@@ -473,9 +396,6 @@ ...@@ -473,9 +396,6 @@
"value": 53, "value": 53,
"keyLabel": "5", "keyLabel": "5",
"names": { "names": {
"web": [
"Digit5"
],
"android": [ "android": [
"5" "5"
], ],
...@@ -500,9 +420,6 @@ ...@@ -500,9 +420,6 @@
"value": 54, "value": 54,
"keyLabel": "6", "keyLabel": "6",
"names": { "names": {
"web": [
"Digit6"
],
"android": [ "android": [
"6" "6"
], ],
...@@ -527,9 +444,6 @@ ...@@ -527,9 +444,6 @@
"value": 55, "value": 55,
"keyLabel": "7", "keyLabel": "7",
"names": { "names": {
"web": [
"Digit7"
],
"android": [ "android": [
"7" "7"
], ],
...@@ -554,9 +468,6 @@ ...@@ -554,9 +468,6 @@
"value": 56, "value": 56,
"keyLabel": "8", "keyLabel": "8",
"names": { "names": {
"web": [
"Digit8"
],
"android": [ "android": [
"8" "8"
], ],
...@@ -581,9 +492,6 @@ ...@@ -581,9 +492,6 @@
"value": 57, "value": 57,
"keyLabel": "9", "keyLabel": "9",
"names": { "names": {
"web": [
"Digit9"
],
"android": [ "android": [
"9" "9"
], ],
...@@ -606,21 +514,13 @@ ...@@ -606,21 +514,13 @@
"Colon": { "Colon": {
"name": "Colon", "name": "Colon",
"value": 58, "value": 58,
"keyLabel": ":", "keyLabel": ":"
"names": {
"web": [
"Colon"
]
}
}, },
"Semicolon": { "Semicolon": {
"name": "Semicolon", "name": "Semicolon",
"value": 59, "value": 59,
"keyLabel": ";", "keyLabel": ";",
"names": { "names": {
"web": [
"Semicolon"
],
"windows": [ "windows": [
"OEM_1" "OEM_1"
], ],
...@@ -649,21 +549,13 @@ ...@@ -649,21 +549,13 @@
"Less": { "Less": {
"name": "Less", "name": "Less",
"value": 60, "value": 60,
"keyLabel": "<", "keyLabel": "<"
"names": {
"web": [
"Less"
]
}
}, },
"Equal": { "Equal": {
"name": "Equal", "name": "Equal",
"value": 61, "value": 61,
"keyLabel": "=", "keyLabel": "=",
"names": { "names": {
"web": [
"Equal"
],
"windows": [ "windows": [
"OEM_PLUS" "OEM_PLUS"
], ],
...@@ -692,31 +584,18 @@ ...@@ -692,31 +584,18 @@
"Greater": { "Greater": {
"name": "Greater", "name": "Greater",
"value": 62, "value": 62,
"keyLabel": ">", "keyLabel": ">"
"names": {
"web": [
"Greater"
]
}
}, },
"Question": { "Question": {
"name": "Question", "name": "Question",
"value": 63, "value": 63,
"keyLabel": "?", "keyLabel": "?"
"names": {
"web": [
"Question"
]
}
}, },
"At": { "At": {
"name": "At", "name": "At",
"value": 64, "value": 64,
"keyLabel": "@", "keyLabel": "@",
"names": { "names": {
"web": [
"At"
],
"android": [ "android": [
"AT" "AT"
] ]
...@@ -732,9 +611,6 @@ ...@@ -732,9 +611,6 @@
"value": 91, "value": 91,
"keyLabel": "[", "keyLabel": "[",
"names": { "names": {
"web": [
"BracketLeft"
],
"windows": [ "windows": [
"OEM_4" "OEM_4"
], ],
...@@ -765,9 +641,6 @@ ...@@ -765,9 +641,6 @@
"value": 92, "value": 92,
"keyLabel": "\\", "keyLabel": "\\",
"names": { "names": {
"web": [
"Backslash"
],
"windows": [ "windows": [
"OEM_5" "OEM_5"
], ],
...@@ -798,9 +671,6 @@ ...@@ -798,9 +671,6 @@
"value": 93, "value": 93,
"keyLabel": "]", "keyLabel": "]",
"names": { "names": {
"web": [
"BracketRight"
],
"windows": [ "windows": [
"OEM_6" "OEM_6"
], ],
...@@ -829,31 +699,18 @@ ...@@ -829,31 +699,18 @@
"Caret": { "Caret": {
"name": "Caret", "name": "Caret",
"value": 94, "value": 94,
"keyLabel": "^", "keyLabel": "^"
"names": {
"web": [
"Caret"
]
}
}, },
"Underscore": { "Underscore": {
"name": "Underscore", "name": "Underscore",
"value": 95, "value": 95,
"keyLabel": "_", "keyLabel": "_"
"names": {
"web": [
"Underscore"
]
}
}, },
"Backquote": { "Backquote": {
"name": "Backquote", "name": "Backquote",
"value": 96, "value": 96,
"keyLabel": "`", "keyLabel": "`",
"names": { "names": {
"web": [
"Backquote"
],
"windows": [ "windows": [
"OEM_3" "OEM_3"
], ],
...@@ -884,9 +741,6 @@ ...@@ -884,9 +741,6 @@
"value": 97, "value": 97,
"keyLabel": "a", "keyLabel": "a",
"names": { "names": {
"web": [
"KeyA"
],
"android": [ "android": [
"A" "A"
], ],
...@@ -911,9 +765,6 @@ ...@@ -911,9 +765,6 @@
"value": 98, "value": 98,
"keyLabel": "b", "keyLabel": "b",
"names": { "names": {
"web": [
"KeyB"
],
"android": [ "android": [
"B" "B"
], ],
...@@ -938,9 +789,6 @@ ...@@ -938,9 +789,6 @@
"value": 99, "value": 99,
"keyLabel": "c", "keyLabel": "c",
"names": { "names": {
"web": [
"KeyC"
],
"android": [ "android": [
"C" "C"
], ],
...@@ -965,9 +813,6 @@ ...@@ -965,9 +813,6 @@
"value": 100, "value": 100,
"keyLabel": "d", "keyLabel": "d",
"names": { "names": {
"web": [
"KeyD"
],
"android": [ "android": [
"D" "D"
], ],
...@@ -992,9 +837,6 @@ ...@@ -992,9 +837,6 @@
"value": 101, "value": 101,
"keyLabel": "e", "keyLabel": "e",
"names": { "names": {
"web": [
"KeyE"
],
"android": [ "android": [
"E" "E"
], ],
...@@ -1019,9 +861,6 @@ ...@@ -1019,9 +861,6 @@
"value": 102, "value": 102,
"keyLabel": "f", "keyLabel": "f",
"names": { "names": {
"web": [
"KeyF"
],
"android": [ "android": [
"F" "F"
], ],
...@@ -1046,9 +885,6 @@ ...@@ -1046,9 +885,6 @@
"value": 103, "value": 103,
"keyLabel": "g", "keyLabel": "g",
"names": { "names": {
"web": [
"KeyG"
],
"android": [ "android": [
"G" "G"
], ],
...@@ -1073,9 +909,6 @@ ...@@ -1073,9 +909,6 @@
"value": 104, "value": 104,
"keyLabel": "h", "keyLabel": "h",
"names": { "names": {
"web": [
"KeyH"
],
"android": [ "android": [
"H" "H"
], ],
...@@ -1100,9 +933,6 @@ ...@@ -1100,9 +933,6 @@
"value": 105, "value": 105,
"keyLabel": "i", "keyLabel": "i",
"names": { "names": {
"web": [
"KeyI"
],
"android": [ "android": [
"I" "I"
], ],
...@@ -1127,9 +957,6 @@ ...@@ -1127,9 +957,6 @@
"value": 106, "value": 106,
"keyLabel": "j", "keyLabel": "j",
"names": { "names": {
"web": [
"KeyJ"
],
"android": [ "android": [
"J" "J"
], ],
...@@ -1154,9 +981,6 @@ ...@@ -1154,9 +981,6 @@
"value": 107, "value": 107,
"keyLabel": "k", "keyLabel": "k",
"names": { "names": {
"web": [
"KeyK"
],
"android": [ "android": [
"K" "K"
], ],
...@@ -1181,9 +1005,6 @@ ...@@ -1181,9 +1005,6 @@
"value": 108, "value": 108,
"keyLabel": "l", "keyLabel": "l",
"names": { "names": {
"web": [
"KeyL"
],
"android": [ "android": [
"L" "L"
], ],
...@@ -1208,9 +1029,6 @@ ...@@ -1208,9 +1029,6 @@
"value": 109, "value": 109,
"keyLabel": "m", "keyLabel": "m",
"names": { "names": {
"web": [
"KeyM"
],
"android": [ "android": [
"M" "M"
], ],
...@@ -1235,9 +1053,6 @@ ...@@ -1235,9 +1053,6 @@
"value": 110, "value": 110,
"keyLabel": "n", "keyLabel": "n",
"names": { "names": {
"web": [
"KeyN"
],
"android": [ "android": [
"N" "N"
], ],
...@@ -1262,9 +1077,6 @@ ...@@ -1262,9 +1077,6 @@
"value": 111, "value": 111,
"keyLabel": "o", "keyLabel": "o",
"names": { "names": {
"web": [
"KeyO"
],
"android": [ "android": [
"O" "O"
], ],
...@@ -1289,9 +1101,6 @@ ...@@ -1289,9 +1101,6 @@
"value": 112, "value": 112,
"keyLabel": "p", "keyLabel": "p",
"names": { "names": {
"web": [
"KeyP"
],
"android": [ "android": [
"P" "P"
], ],
...@@ -1316,9 +1125,6 @@ ...@@ -1316,9 +1125,6 @@
"value": 113, "value": 113,
"keyLabel": "q", "keyLabel": "q",
"names": { "names": {
"web": [
"KeyQ"
],
"android": [ "android": [
"Q" "Q"
], ],
...@@ -1343,9 +1149,6 @@ ...@@ -1343,9 +1149,6 @@
"value": 114, "value": 114,
"keyLabel": "r", "keyLabel": "r",
"names": { "names": {
"web": [
"KeyR"
],
"android": [ "android": [
"R" "R"
], ],
...@@ -1370,9 +1173,6 @@ ...@@ -1370,9 +1173,6 @@
"value": 115, "value": 115,
"keyLabel": "s", "keyLabel": "s",
"names": { "names": {
"web": [
"KeyS"
],
"android": [ "android": [
"S" "S"
], ],
...@@ -1397,9 +1197,6 @@ ...@@ -1397,9 +1197,6 @@
"value": 116, "value": 116,
"keyLabel": "t", "keyLabel": "t",
"names": { "names": {
"web": [
"KeyT"
],
"android": [ "android": [
"T" "T"
], ],
...@@ -1424,9 +1221,6 @@ ...@@ -1424,9 +1221,6 @@
"value": 117, "value": 117,
"keyLabel": "u", "keyLabel": "u",
"names": { "names": {
"web": [
"KeyU"
],
"android": [ "android": [
"U" "U"
], ],
...@@ -1451,9 +1245,6 @@ ...@@ -1451,9 +1245,6 @@
"value": 118, "value": 118,
"keyLabel": "v", "keyLabel": "v",
"names": { "names": {
"web": [
"KeyV"
],
"android": [ "android": [
"V" "V"
], ],
...@@ -1478,9 +1269,6 @@ ...@@ -1478,9 +1269,6 @@
"value": 119, "value": 119,
"keyLabel": "w", "keyLabel": "w",
"names": { "names": {
"web": [
"KeyW"
],
"android": [ "android": [
"W" "W"
], ],
...@@ -1505,9 +1293,6 @@ ...@@ -1505,9 +1293,6 @@
"value": 120, "value": 120,
"keyLabel": "x", "keyLabel": "x",
"names": { "names": {
"web": [
"KeyX"
],
"android": [ "android": [
"X" "X"
], ],
...@@ -1532,9 +1317,6 @@ ...@@ -1532,9 +1317,6 @@
"value": 121, "value": 121,
"keyLabel": "y", "keyLabel": "y",
"names": { "names": {
"web": [
"KeyY"
],
"android": [ "android": [
"Y" "Y"
], ],
...@@ -1559,9 +1341,6 @@ ...@@ -1559,9 +1341,6 @@
"value": 122, "value": 122,
"keyLabel": "z", "keyLabel": "z",
"names": { "names": {
"web": [
"KeyZ"
],
"android": [ "android": [
"Z" "Z"
], ],
...@@ -1584,42 +1363,22 @@ ...@@ -1584,42 +1363,22 @@
"BraceLeft": { "BraceLeft": {
"name": "BraceLeft", "name": "BraceLeft",
"value": 123, "value": 123,
"keyLabel": "{", "keyLabel": "{"
"names": {
"web": [
"BraceLeft"
]
}
}, },
"Bar": { "Bar": {
"name": "Bar", "name": "Bar",
"value": 124, "value": 124,
"keyLabel": "|", "keyLabel": "|"
"names": {
"web": [
"Bar"
]
}
}, },
"BraceRight": { "BraceRight": {
"name": "BraceRight", "name": "BraceRight",
"value": 125, "value": 125,
"keyLabel": "}", "keyLabel": "}"
"names": {
"web": [
"BraceRight"
]
}
}, },
"Tilde": { "Tilde": {
"name": "Tilde", "name": "Tilde",
"value": 126, "value": 126,
"keyLabel": "~", "keyLabel": "~"
"names": {
"web": [
"Tilde"
]
}
}, },
"Unidentified": { "Unidentified": {
"name": "Unidentified", "name": "Unidentified",
...@@ -1633,7 +1392,6 @@ ...@@ -1633,7 +1392,6 @@
"Backspace": { "Backspace": {
"name": "Backspace", "name": "Backspace",
"value": 4294967304, "value": 4294967304,
"keyLabel": "\b",
"names": { "names": {
"web": [ "web": [
"Backspace" "Backspace"
...@@ -1684,7 +1442,6 @@ ...@@ -1684,7 +1442,6 @@
"Tab": { "Tab": {
"name": "Tab", "name": "Tab",
"value": 4294967305, "value": 4294967305,
"keyLabel": "\t",
"names": { "names": {
"web": [ "web": [
"Tab" "Tab"
...@@ -1739,7 +1496,6 @@ ...@@ -1739,7 +1496,6 @@
"Enter": { "Enter": {
"name": "Enter", "name": "Enter",
"value": 4294967309, "value": 4294967309,
"keyLabel": "\r",
"names": { "names": {
"web": [ "web": [
"Enter" "Enter"
...@@ -1794,7 +1550,6 @@ ...@@ -1794,7 +1550,6 @@
"Escape": { "Escape": {
"name": "Escape", "name": "Escape",
"value": 4294967323, "value": 4294967323,
"keyLabel": "\u001b",
"names": { "names": {
"web": [ "web": [
"Escape" "Escape"
...@@ -1845,7 +1600,6 @@ ...@@ -1845,7 +1600,6 @@
"Delete": { "Delete": {
"name": "Delete", "name": "Delete",
"value": 4294967423, "value": 4294967423,
"keyLabel": "",
"names": { "names": {
"web": [ "web": [
"Delete" "Delete"
...@@ -7866,9 +7620,6 @@ ...@@ -7866,9 +7620,6 @@
"name": "Suspend", "name": "Suspend",
"value": 8589934592, "value": 8589934592,
"names": { "names": {
"web": [
"Suspend"
],
"gtk": [ "gtk": [
"Suspend" "Suspend"
] ]
...@@ -7885,11 +7636,6 @@ ...@@ -7885,11 +7636,6 @@
"Resume": { "Resume": {
"name": "Resume", "name": "Resume",
"value": 8589934593, "value": 8589934593,
"names": {
"web": [
"Resume"
]
},
"values": { "values": {
"fuchsia": [ "fuchsia": [
77309411349 77309411349
...@@ -7900,9 +7646,6 @@ ...@@ -7900,9 +7646,6 @@
"name": "Sleep", "name": "Sleep",
"value": 8589934594, "value": 8589934594,
"names": { "names": {
"web": [
"Sleep"
],
"gtk": [ "gtk": [
"Sleep" "Sleep"
], ],
...@@ -7931,11 +7674,6 @@ ...@@ -7931,11 +7674,6 @@
"Abort": { "Abort": {
"name": "Abort", "name": "Abort",
"value": 8589934595, "value": 8589934595,
"names": {
"web": [
"Abort"
]
},
"values": { "values": {
"fuchsia": [ "fuchsia": [
77309870235 77309870235
...@@ -7946,9 +7684,6 @@ ...@@ -7946,9 +7684,6 @@
"name": "Lang1", "name": "Lang1",
"value": 8589934608, "value": 8589934608,
"names": { "names": {
"web": [
"Lang1"
],
"macos": [ "macos": [
"Lang1" "Lang1"
], ],
...@@ -7978,9 +7713,6 @@ ...@@ -7978,9 +7713,6 @@
"name": "Lang2", "name": "Lang2",
"value": 8589934609, "value": 8589934609,
"names": { "names": {
"web": [
"Lang2"
],
"macos": [ "macos": [
"Lang2" "Lang2"
], ],
...@@ -8004,9 +7736,6 @@ ...@@ -8004,9 +7736,6 @@
"name": "Lang3", "name": "Lang3",
"value": 8589934610, "value": 8589934610,
"names": { "names": {
"web": [
"Lang3"
],
"ios": [ "ios": [
"Lang3" "Lang3"
] ]
...@@ -8024,9 +7753,6 @@ ...@@ -8024,9 +7753,6 @@
"name": "Lang4", "name": "Lang4",
"value": 8589934611, "value": 8589934611,
"names": { "names": {
"web": [
"Lang4"
],
"ios": [ "ios": [
"Lang4" "Lang4"
] ]
...@@ -8044,9 +7770,6 @@ ...@@ -8044,9 +7770,6 @@
"name": "Lang5", "name": "Lang5",
"value": 8589934612, "value": 8589934612,
"names": { "names": {
"web": [
"Lang5"
],
"ios": [ "ios": [
"Lang5" "Lang5"
] ]
...@@ -8063,11 +7786,6 @@ ...@@ -8063,11 +7786,6 @@
"IntlBackslash": { "IntlBackslash": {
"name": "IntlBackslash", "name": "IntlBackslash",
"value": 8589934624, "value": 8589934624,
"names": {
"web": [
"IntlBackslash"
]
},
"values": { "values": {
"fuchsia": [ "fuchsia": [
77309870180 77309870180
...@@ -8078,9 +7796,6 @@ ...@@ -8078,9 +7796,6 @@
"name": "IntlRo", "name": "IntlRo",
"value": 8589934625, "value": 8589934625,
"names": { "names": {
"web": [
"IntlRo"
],
"macos": [ "macos": [
"IntlRo" "IntlRo"
], ],
...@@ -8110,9 +7825,6 @@ ...@@ -8110,9 +7825,6 @@
"name": "IntlYen", "name": "IntlYen",
"value": 8589934626, "value": 8589934626,
"names": { "names": {
"web": [
"IntlYen"
],
"macos": [ "macos": [
"IntlYen" "IntlYen"
], ],
...@@ -8148,9 +7860,6 @@ ...@@ -8148,9 +7860,6 @@
"name": "ControlLeft", "name": "ControlLeft",
"value": 8589934848, "value": 8589934848,
"names": { "names": {
"web": [
"ControlLeft"
],
"macos": [ "macos": [
"ControlLeft" "ControlLeft"
], ],
...@@ -8200,9 +7909,6 @@ ...@@ -8200,9 +7909,6 @@
"name": "ControlRight", "name": "ControlRight",
"value": 8589934849, "value": 8589934849,
"names": { "names": {
"web": [
"ControlRight"
],
"macos": [ "macos": [
"ControlRight" "ControlRight"
], ],
...@@ -8250,9 +7956,6 @@ ...@@ -8250,9 +7956,6 @@
"name": "ShiftLeft", "name": "ShiftLeft",
"value": 8589934850, "value": 8589934850,
"names": { "names": {
"web": [
"ShiftLeft"
],
"macos": [ "macos": [
"ShiftLeft" "ShiftLeft"
], ],
...@@ -8302,9 +8005,6 @@ ...@@ -8302,9 +8005,6 @@
"name": "ShiftRight", "name": "ShiftRight",
"value": 8589934851, "value": 8589934851,
"names": { "names": {
"web": [
"ShiftRight"
],
"macos": [ "macos": [
"ShiftRight" "ShiftRight"
], ],
...@@ -8352,9 +8052,6 @@ ...@@ -8352,9 +8052,6 @@
"name": "AltLeft", "name": "AltLeft",
"value": 8589934852, "value": 8589934852,
"names": { "names": {
"web": [
"AltLeft"
],
"macos": [ "macos": [
"AltLeft" "AltLeft"
], ],
...@@ -8402,9 +8099,6 @@ ...@@ -8402,9 +8099,6 @@
"name": "AltRight", "name": "AltRight",
"value": 8589934853, "value": 8589934853,
"names": { "names": {
"web": [
"AltRight"
],
"macos": [ "macos": [
"AltRight" "AltRight"
], ],
...@@ -8454,9 +8148,6 @@ ...@@ -8454,9 +8148,6 @@
"name": "MetaLeft", "name": "MetaLeft",
"value": 8589934854, "value": 8589934854,
"names": { "names": {
"web": [
"MetaLeft"
],
"macos": [ "macos": [
"MetaLeft" "MetaLeft"
], ],
...@@ -8504,9 +8195,6 @@ ...@@ -8504,9 +8195,6 @@
"name": "MetaRight", "name": "MetaRight",
"value": 8589934855, "value": 8589934855,
"names": { "names": {
"web": [
"MetaRight"
],
"macos": [ "macos": [
"MetaRight" "MetaRight"
], ],
...@@ -8552,47 +8240,24 @@ ...@@ -8552,47 +8240,24 @@
}, },
"Control": { "Control": {
"name": "Control", "name": "Control",
"value": 8589935088, "value": 8589935088
"names": {
"web": [
"Control"
]
}
}, },
"Shift": { "Shift": {
"name": "Shift", "name": "Shift",
"value": 8589935090, "value": 8589935090
"names": {
"web": [
"Shift"
]
}
}, },
"Alt": { "Alt": {
"name": "Alt", "name": "Alt",
"value": 8589935092, "value": 8589935092
"names": {
"web": [
"Alt"
]
}
}, },
"Meta": { "Meta": {
"name": "Meta", "name": "Meta",
"value": 8589935094, "value": 8589935094
"names": {
"web": [
"Meta"
]
}
}, },
"NumpadEnter": { "NumpadEnter": {
"name": "NumpadEnter", "name": "NumpadEnter",
"value": 8589935117, "value": 8589935117,
"names": { "names": {
"web": [
"NumpadEnter"
],
"macos": [ "macos": [
"NumpadEnter" "NumpadEnter"
], ],
...@@ -8634,9 +8299,6 @@ ...@@ -8634,9 +8299,6 @@
"name": "NumpadParenLeft", "name": "NumpadParenLeft",
"value": 8589935144, "value": 8589935144,
"names": { "names": {
"web": [
"NumpadParenLeft"
],
"android": [ "android": [
"NUMPAD_LEFT_PAREN" "NUMPAD_LEFT_PAREN"
] ]
...@@ -8654,9 +8316,6 @@ ...@@ -8654,9 +8316,6 @@
"name": "NumpadParenRight", "name": "NumpadParenRight",
"value": 8589935145, "value": 8589935145,
"names": { "names": {
"web": [
"NumpadParenRight"
],
"android": [ "android": [
"NUMPAD_RIGHT_PAREN" "NUMPAD_RIGHT_PAREN"
] ]
...@@ -8674,9 +8333,6 @@ ...@@ -8674,9 +8333,6 @@
"name": "NumpadMultiply", "name": "NumpadMultiply",
"value": 8589935146, "value": 8589935146,
"names": { "names": {
"web": [
"NumpadMultiply"
],
"macos": [ "macos": [
"NumpadMultiply" "NumpadMultiply"
], ],
...@@ -8724,9 +8380,6 @@ ...@@ -8724,9 +8380,6 @@
"name": "NumpadAdd", "name": "NumpadAdd",
"value": 8589935147, "value": 8589935147,
"names": { "names": {
"web": [
"NumpadAdd"
],
"macos": [ "macos": [
"NumpadAdd" "NumpadAdd"
], ],
...@@ -8774,9 +8427,6 @@ ...@@ -8774,9 +8427,6 @@
"name": "NumpadComma", "name": "NumpadComma",
"value": 8589935148, "value": 8589935148,
"names": { "names": {
"web": [
"NumpadComma"
],
"macos": [ "macos": [
"NumpadComma" "NumpadComma"
], ],
...@@ -8812,9 +8462,6 @@ ...@@ -8812,9 +8462,6 @@
"name": "NumpadSubtract", "name": "NumpadSubtract",
"value": 8589935149, "value": 8589935149,
"names": { "names": {
"web": [
"NumpadSubtract"
],
"macos": [ "macos": [
"NumpadSubtract" "NumpadSubtract"
], ],
...@@ -8856,9 +8503,6 @@ ...@@ -8856,9 +8503,6 @@
"name": "NumpadDecimal", "name": "NumpadDecimal",
"value": 8589935150, "value": 8589935150,
"names": { "names": {
"web": [
"NumpadDecimal"
],
"macos": [ "macos": [
"NumpadDecimal" "NumpadDecimal"
], ],
...@@ -8906,9 +8550,6 @@ ...@@ -8906,9 +8550,6 @@
"name": "NumpadDivide", "name": "NumpadDivide",
"value": 8589935151, "value": 8589935151,
"names": { "names": {
"web": [
"NumpadDivide"
],
"macos": [ "macos": [
"NumpadDivide" "NumpadDivide"
], ],
...@@ -8956,9 +8597,6 @@ ...@@ -8956,9 +8597,6 @@
"name": "Numpad0", "name": "Numpad0",
"value": 8589935152, "value": 8589935152,
"names": { "names": {
"web": [
"Numpad0"
],
"macos": [ "macos": [
"Numpad0" "Numpad0"
], ],
...@@ -9008,9 +8646,6 @@ ...@@ -9008,9 +8646,6 @@
"name": "Numpad1", "name": "Numpad1",
"value": 8589935153, "value": 8589935153,
"names": { "names": {
"web": [
"Numpad1"
],
"macos": [ "macos": [
"Numpad1" "Numpad1"
], ],
...@@ -9060,9 +8695,6 @@ ...@@ -9060,9 +8695,6 @@
"name": "Numpad2", "name": "Numpad2",
"value": 8589935154, "value": 8589935154,
"names": { "names": {
"web": [
"Numpad2"
],
"macos": [ "macos": [
"Numpad2" "Numpad2"
], ],
...@@ -9112,9 +8744,6 @@ ...@@ -9112,9 +8744,6 @@
"name": "Numpad3", "name": "Numpad3",
"value": 8589935155, "value": 8589935155,
"names": { "names": {
"web": [
"Numpad3"
],
"macos": [ "macos": [
"Numpad3" "Numpad3"
], ],
...@@ -9164,9 +8793,6 @@ ...@@ -9164,9 +8793,6 @@
"name": "Numpad4", "name": "Numpad4",
"value": 8589935156, "value": 8589935156,
"names": { "names": {
"web": [
"Numpad4"
],
"macos": [ "macos": [
"Numpad4" "Numpad4"
], ],
...@@ -9216,9 +8842,6 @@ ...@@ -9216,9 +8842,6 @@
"name": "Numpad5", "name": "Numpad5",
"value": 8589935157, "value": 8589935157,
"names": { "names": {
"web": [
"Numpad5"
],
"macos": [ "macos": [
"Numpad5" "Numpad5"
], ],
...@@ -9266,9 +8889,6 @@ ...@@ -9266,9 +8889,6 @@
"name": "Numpad6", "name": "Numpad6",
"value": 8589935158, "value": 8589935158,
"names": { "names": {
"web": [
"Numpad6"
],
"macos": [ "macos": [
"Numpad6" "Numpad6"
], ],
...@@ -9318,9 +8938,6 @@ ...@@ -9318,9 +8938,6 @@
"name": "Numpad7", "name": "Numpad7",
"value": 8589935159, "value": 8589935159,
"names": { "names": {
"web": [
"Numpad7"
],
"macos": [ "macos": [
"Numpad7" "Numpad7"
], ],
...@@ -9370,9 +8987,6 @@ ...@@ -9370,9 +8987,6 @@
"name": "Numpad8", "name": "Numpad8",
"value": 8589935160, "value": 8589935160,
"names": { "names": {
"web": [
"Numpad8"
],
"macos": [ "macos": [
"Numpad8" "Numpad8"
], ],
...@@ -9422,9 +9036,6 @@ ...@@ -9422,9 +9036,6 @@
"name": "Numpad9", "name": "Numpad9",
"value": 8589935161, "value": 8589935161,
"names": { "names": {
"web": [
"Numpad9"
],
"macos": [ "macos": [
"Numpad9" "Numpad9"
], ],
...@@ -9474,9 +9085,6 @@ ...@@ -9474,9 +9085,6 @@
"name": "NumpadEqual", "name": "NumpadEqual",
"value": 8589935165, "value": 8589935165,
"names": { "names": {
"web": [
"NumpadEqual"
],
"macos": [ "macos": [
"NumpadEqual" "NumpadEqual"
], ],
...@@ -9524,9 +9132,6 @@ ...@@ -9524,9 +9132,6 @@
"name": "GameButton1", "name": "GameButton1",
"value": 8589935361, "value": 8589935361,
"names": { "names": {
"web": [
"GameButton1"
],
"android": [ "android": [
"BUTTON_1" "BUTTON_1"
] ]
...@@ -9544,9 +9149,6 @@ ...@@ -9544,9 +9149,6 @@
"name": "GameButton2", "name": "GameButton2",
"value": 8589935362, "value": 8589935362,
"names": { "names": {
"web": [
"GameButton2"
],
"android": [ "android": [
"BUTTON_2" "BUTTON_2"
] ]
...@@ -9564,9 +9166,6 @@ ...@@ -9564,9 +9166,6 @@
"name": "GameButton3", "name": "GameButton3",
"value": 8589935363, "value": 8589935363,
"names": { "names": {
"web": [
"GameButton3"
],
"android": [ "android": [
"BUTTON_3" "BUTTON_3"
] ]
...@@ -9584,9 +9183,6 @@ ...@@ -9584,9 +9183,6 @@
"name": "GameButton4", "name": "GameButton4",
"value": 8589935364, "value": 8589935364,
"names": { "names": {
"web": [
"GameButton4"
],
"android": [ "android": [
"BUTTON_4" "BUTTON_4"
] ]
...@@ -9604,9 +9200,6 @@ ...@@ -9604,9 +9200,6 @@
"name": "GameButton5", "name": "GameButton5",
"value": 8589935365, "value": 8589935365,
"names": { "names": {
"web": [
"GameButton5"
],
"android": [ "android": [
"BUTTON_5" "BUTTON_5"
] ]
...@@ -9624,9 +9217,6 @@ ...@@ -9624,9 +9217,6 @@
"name": "GameButton6", "name": "GameButton6",
"value": 8589935366, "value": 8589935366,
"names": { "names": {
"web": [
"GameButton6"
],
"android": [ "android": [
"BUTTON_6" "BUTTON_6"
] ]
...@@ -9644,9 +9234,6 @@ ...@@ -9644,9 +9234,6 @@
"name": "GameButton7", "name": "GameButton7",
"value": 8589935367, "value": 8589935367,
"names": { "names": {
"web": [
"GameButton7"
],
"android": [ "android": [
"BUTTON_7" "BUTTON_7"
] ]
...@@ -9664,9 +9251,6 @@ ...@@ -9664,9 +9251,6 @@
"name": "GameButton8", "name": "GameButton8",
"value": 8589935368, "value": 8589935368,
"names": { "names": {
"web": [
"GameButton8"
],
"windows": [ "windows": [
"GAMEPAD_A" "GAMEPAD_A"
], ],
...@@ -9690,9 +9274,6 @@ ...@@ -9690,9 +9274,6 @@
"name": "GameButton9", "name": "GameButton9",
"value": 8589935369, "value": 8589935369,
"names": { "names": {
"web": [
"GameButton9"
],
"windows": [ "windows": [
"GAMEPAD_B" "GAMEPAD_B"
], ],
...@@ -9716,9 +9297,6 @@ ...@@ -9716,9 +9297,6 @@
"name": "GameButton10", "name": "GameButton10",
"value": 8589935370, "value": 8589935370,
"names": { "names": {
"web": [
"GameButton10"
],
"windows": [ "windows": [
"GAMEPAD_X" "GAMEPAD_X"
], ],
...@@ -9742,9 +9320,6 @@ ...@@ -9742,9 +9320,6 @@
"name": "GameButton11", "name": "GameButton11",
"value": 8589935371, "value": 8589935371,
"names": { "names": {
"web": [
"GameButton11"
],
"windows": [ "windows": [
"GAMEPAD_Y" "GAMEPAD_Y"
], ],
...@@ -9768,9 +9343,6 @@ ...@@ -9768,9 +9343,6 @@
"name": "GameButton12", "name": "GameButton12",
"value": 8589935372, "value": 8589935372,
"names": { "names": {
"web": [
"GameButton12"
],
"windows": [ "windows": [
"GAMEPAD_RIGHT_SHOULDER" "GAMEPAD_RIGHT_SHOULDER"
], ],
...@@ -9794,9 +9366,6 @@ ...@@ -9794,9 +9366,6 @@
"name": "GameButton13", "name": "GameButton13",
"value": 8589935373, "value": 8589935373,
"names": { "names": {
"web": [
"GameButton13"
],
"windows": [ "windows": [
"GAMEPAD_LEFT_SHOULDER" "GAMEPAD_LEFT_SHOULDER"
], ],
...@@ -9820,9 +9389,6 @@ ...@@ -9820,9 +9389,6 @@
"name": "GameButton14", "name": "GameButton14",
"value": 8589935374, "value": 8589935374,
"names": { "names": {
"web": [
"GameButton14"
],
"windows": [ "windows": [
"GAMEPAD_LEFT_TRIGGER" "GAMEPAD_LEFT_TRIGGER"
], ],
...@@ -9846,9 +9412,6 @@ ...@@ -9846,9 +9412,6 @@
"name": "GameButton15", "name": "GameButton15",
"value": 8589935375, "value": 8589935375,
"names": { "names": {
"web": [
"GameButton15"
],
"windows": [ "windows": [
"GAMEPAD_RIGHT_TRIGGER" "GAMEPAD_RIGHT_TRIGGER"
], ],
...@@ -9872,9 +9435,6 @@ ...@@ -9872,9 +9435,6 @@
"name": "GameButton16", "name": "GameButton16",
"value": 8589935376, "value": 8589935376,
"names": { "names": {
"web": [
"GameButton16"
],
"windows": [ "windows": [
"GAMEPAD_DPAD_UP" "GAMEPAD_DPAD_UP"
], ],
...@@ -9898,9 +9458,6 @@ ...@@ -9898,9 +9458,6 @@
"name": "GameButtonA", "name": "GameButtonA",
"value": 8589935377, "value": 8589935377,
"names": { "names": {
"web": [
"GameButtonA"
],
"android": [ "android": [
"BUTTON_A" "BUTTON_A"
] ]
...@@ -9918,9 +9475,6 @@ ...@@ -9918,9 +9475,6 @@
"name": "GameButtonB", "name": "GameButtonB",
"value": 8589935378, "value": 8589935378,
"names": { "names": {
"web": [
"GameButtonB"
],
"android": [ "android": [
"BUTTON_B" "BUTTON_B"
] ]
...@@ -9938,9 +9492,6 @@ ...@@ -9938,9 +9492,6 @@
"name": "GameButtonC", "name": "GameButtonC",
"value": 8589935379, "value": 8589935379,
"names": { "names": {
"web": [
"GameButtonC"
],
"android": [ "android": [
"BUTTON_C" "BUTTON_C"
] ]
...@@ -9958,9 +9509,6 @@ ...@@ -9958,9 +9509,6 @@
"name": "GameButtonLeft1", "name": "GameButtonLeft1",
"value": 8589935380, "value": 8589935380,
"names": { "names": {
"web": [
"GameButtonLeft1"
],
"android": [ "android": [
"BUTTON_L1" "BUTTON_L1"
] ]
...@@ -9978,9 +9526,6 @@ ...@@ -9978,9 +9526,6 @@
"name": "GameButtonLeft2", "name": "GameButtonLeft2",
"value": 8589935381, "value": 8589935381,
"names": { "names": {
"web": [
"GameButtonLeft2"
],
"android": [ "android": [
"BUTTON_L2" "BUTTON_L2"
] ]
...@@ -9998,9 +9543,6 @@ ...@@ -9998,9 +9543,6 @@
"name": "GameButtonMode", "name": "GameButtonMode",
"value": 8589935382, "value": 8589935382,
"names": { "names": {
"web": [
"GameButtonMode"
],
"android": [ "android": [
"BUTTON_MODE" "BUTTON_MODE"
] ]
...@@ -10018,9 +9560,6 @@ ...@@ -10018,9 +9560,6 @@
"name": "GameButtonRight1", "name": "GameButtonRight1",
"value": 8589935383, "value": 8589935383,
"names": { "names": {
"web": [
"GameButtonRight1"
],
"android": [ "android": [
"BUTTON_R1" "BUTTON_R1"
] ]
...@@ -10038,9 +9577,6 @@ ...@@ -10038,9 +9577,6 @@
"name": "GameButtonRight2", "name": "GameButtonRight2",
"value": 8589935384, "value": 8589935384,
"names": { "names": {
"web": [
"GameButtonRight2"
],
"android": [ "android": [
"BUTTON_R2" "BUTTON_R2"
] ]
...@@ -10058,9 +9594,6 @@ ...@@ -10058,9 +9594,6 @@
"name": "GameButtonSelect", "name": "GameButtonSelect",
"value": 8589935385, "value": 8589935385,
"names": { "names": {
"web": [
"GameButtonSelect"
],
"android": [ "android": [
"BUTTON_SELECT" "BUTTON_SELECT"
] ]
...@@ -10078,9 +9611,6 @@ ...@@ -10078,9 +9611,6 @@
"name": "GameButtonStart", "name": "GameButtonStart",
"value": 8589935386, "value": 8589935386,
"names": { "names": {
"web": [
"GameButtonStart"
],
"android": [ "android": [
"BUTTON_START" "BUTTON_START"
] ]
...@@ -10098,9 +9628,6 @@ ...@@ -10098,9 +9628,6 @@
"name": "GameButtonThumbLeft", "name": "GameButtonThumbLeft",
"value": 8589935387, "value": 8589935387,
"names": { "names": {
"web": [
"GameButtonThumbLeft"
],
"android": [ "android": [
"BUTTON_THUMBL" "BUTTON_THUMBL"
] ]
...@@ -10118,9 +9645,6 @@ ...@@ -10118,9 +9645,6 @@
"name": "GameButtonThumbRight", "name": "GameButtonThumbRight",
"value": 8589935388, "value": 8589935388,
"names": { "names": {
"web": [
"GameButtonThumbRight"
],
"android": [ "android": [
"BUTTON_THUMBR" "BUTTON_THUMBR"
] ]
...@@ -10138,9 +9662,6 @@ ...@@ -10138,9 +9662,6 @@
"name": "GameButtonX", "name": "GameButtonX",
"value": 8589935389, "value": 8589935389,
"names": { "names": {
"web": [
"GameButtonX"
],
"android": [ "android": [
"BUTTON_X" "BUTTON_X"
] ]
...@@ -10158,9 +9679,6 @@ ...@@ -10158,9 +9679,6 @@
"name": "GameButtonY", "name": "GameButtonY",
"value": 8589935390, "value": 8589935390,
"names": { "names": {
"web": [
"GameButtonY"
],
"android": [ "android": [
"BUTTON_Y" "BUTTON_Y"
] ]
...@@ -10178,9 +9696,6 @@ ...@@ -10178,9 +9696,6 @@
"name": "GameButtonZ", "name": "GameButtonZ",
"value": 8589935391, "value": 8589935391,
"names": { "names": {
"web": [
"GameButtonZ"
],
"android": [ "android": [
"BUTTON_Z" "BUTTON_Z"
] ]
......
...@@ -11,11 +11,7 @@ import 'package:path/path.dart' as path; ...@@ -11,11 +11,7 @@ import 'package:path/path.dart' as path;
import 'constants.dart'; import 'constants.dart';
import 'physical_key_data.dart'; import 'physical_key_data.dart';
bool _isControlCharacter(String label) { bool _isControlCharacter(int codeUnit) {
if (label.length != 1) {
return false;
}
final int codeUnit = label.codeUnitAt(0);
return (codeUnit <= 0x1f && codeUnit >= 0x00) || (codeUnit >= 0x7f && codeUnit <= 0x9f); return (codeUnit <= 0x1f && codeUnit >= 0x00) || (codeUnit >= 0x7f && codeUnit <= 0x9f);
} }
...@@ -27,8 +23,11 @@ class _ModifierPair { ...@@ -27,8 +23,11 @@ class _ModifierPair {
final String right; final String right;
} }
List<T> _toNonEmptyArray<T>(dynamic source) { // Return map[key1][key2] as a non-nullable List<T>, where both map[key1] or
final List<dynamic>? dynamicNullableList = source as List<dynamic>?; // map[key1][key2] might be null.
List<T> _getGrandchildList<T>(Map<String, dynamic> map, String key1, String key2) {
final dynamic value = (map[key1] as Map<String, dynamic>?)?[key2];
final List<dynamic>? dynamicNullableList = value as List<dynamic>?;
final List<dynamic> dynamicList = dynamicNullableList ?? <dynamic>[]; final List<dynamic> dynamicList = dynamicNullableList ?? <dynamic>[];
return dynamicList.cast<T>(); return dynamicList.cast<T>();
} }
...@@ -155,20 +154,23 @@ class LogicalKeyData { ...@@ -155,20 +154,23 @@ class LogicalKeyData {
final int value = match.namedGroup('unicode') != null ? final int value = match.namedGroup('unicode') != null ?
getHex(match.namedGroup('unicode')!) : getHex(match.namedGroup('unicode')!) :
match.namedGroup('char')!.codeUnitAt(0); match.namedGroup('char')!.codeUnitAt(0);
final String? keyLabel = match.namedGroup('kind')! == 'UNI' ? String.fromCharCode(value) : null; final String? keyLabel = (match.namedGroup('kind')! == 'UNI' && !_isControlCharacter(value)) ?
String.fromCharCode(value) : null;
// Skip modifier keys from DOM. They will be added with supplemental data. // Skip modifier keys from DOM. They will be added with supplemental data.
if (_chromeModifiers.containsKey(name) && source == 'DOM') { if (_chromeModifiers.containsKey(name) && source == 'DOM') {
continue; continue;
} }
final bool isPrintable = (keyLabel != null && !_isControlCharacter(keyLabel)) final bool isPrintable = keyLabel != null;
|| printable.containsKey(name);
data.putIfAbsent(name, () { data.putIfAbsent(name, () {
return LogicalKeyEntry.fromName( final LogicalKeyEntry entry = LogicalKeyEntry.fromName(
value: toPlane(value, _sourceToPlane(source, isPrintable)), value: toPlane(value, _sourceToPlane(source, isPrintable)),
name: name, name: name,
keyLabel: keyLabel, keyLabel: keyLabel,
)..webNames.add(webName); );
if (source == 'DOM' && !isPrintable)
entry.webNames.add(webName);
return entry;
}); });
} }
} }
...@@ -418,9 +420,11 @@ class LogicalKeyData { ...@@ -418,9 +420,11 @@ class LogicalKeyData {
})(); })();
static int _sourceToPlane(String source, bool isPrintable) { static int _sourceToPlane(String source, bool isPrintable) {
if (isPrintable)
return kUnicodePlane.value;
switch (source) { switch (source) {
case 'DOM': case 'DOM':
return isPrintable ? kUnicodePlane.value : kUnprintablePlane.value; return kUnprintablePlane.value;
case 'FLUTTER': case 'FLUTTER':
return kFlutterPlane.value; return kFlutterPlane.value;
default: default:
...@@ -470,20 +474,20 @@ class LogicalKeyEntry { ...@@ -470,20 +474,20 @@ class LogicalKeyEntry {
LogicalKeyEntry.fromJsonMapEntry(Map<String, dynamic> map) LogicalKeyEntry.fromJsonMapEntry(Map<String, dynamic> map)
: value = map['value'] as int, : value = map['value'] as int,
name = map['name'] as String, name = map['name'] as String,
webNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['web']), webNames = _getGrandchildList<String>(map, 'names', 'web'),
macOSKeyCodeNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['macos']), macOSKeyCodeNames = _getGrandchildList<String>(map, 'names', 'macos'),
macOSKeyCodeValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['macos']), macOSKeyCodeValues = _getGrandchildList<int>(map, 'values', 'macos'),
iOSKeyCodeNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['ios']), iOSKeyCodeNames = _getGrandchildList<String>(map, 'names', 'ios'),
iOSKeyCodeValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['ios']), iOSKeyCodeValues = _getGrandchildList<int>(map, 'values', 'ios'),
gtkNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['gtk']), gtkNames = _getGrandchildList<String>(map, 'names', 'gtk'),
gtkValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['gtk']), gtkValues = _getGrandchildList<int>(map, 'values', 'gtk'),
windowsNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['windows']), windowsNames = _getGrandchildList<String>(map, 'names', 'windows'),
windowsValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['windows']), windowsValues = _getGrandchildList<int>(map, 'values', 'windows'),
androidNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['android']), androidNames = _getGrandchildList<String>(map, 'names', 'android'),
androidValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['android']), androidValues = _getGrandchildList<int>(map, 'values', 'android'),
fuchsiaValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['fuchsia']), fuchsiaValues = _getGrandchildList<int>(map, 'values', 'fuchsia'),
glfwNames = _toNonEmptyArray<String>((map['names'] as Map<String, dynamic>)['glfw']), glfwNames = _getGrandchildList<String>(map, 'names', 'glfw'),
glfwValues = _toNonEmptyArray<int>((map['values'] as Map<String, dynamic>?)?['glfw']), glfwValues = _getGrandchildList<int>(map, 'values', 'glfw'),
keyLabel = map['keyLabel'] as String?; keyLabel = map['keyLabel'] as String?;
final int value; final int value;
......
...@@ -22,8 +22,10 @@ String readDataFile(String fileName) { ...@@ -22,8 +22,10 @@ String readDataFile(String fileName) {
return File(path.join(dataRoot, fileName)).readAsStringSync(); return File(path.join(dataRoot, fileName)).readAsStringSync();
} }
final String testPhysicalData = path.join(dataRoot, 'physical_key_data.json'); final PhysicalKeyData physicalData = PhysicalKeyData.fromJson(
final String testLogicalData = path.join(dataRoot,'logical_key_data.json'); json.decode(readDataFile('physical_key_data.json')) as Map<String, dynamic>);
final LogicalKeyData logicalData = LogicalKeyData.fromJson(
json.decode(readDataFile('logical_key_data.json')) as Map<String, dynamic>);
void main() { void main() {
setUp(() { setUp(() {
...@@ -45,14 +47,6 @@ void main() { ...@@ -45,14 +47,6 @@ void main() {
} }
test('Generate Keycodes for Android', () { test('Generate Keycodes for Android', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'android'; const String platform = 'android';
final PlatformCodeGenerator codeGenerator = AndroidCodeGenerator( final PlatformCodeGenerator codeGenerator = AndroidCodeGenerator(
physicalData, physicalData,
...@@ -67,14 +61,6 @@ void main() { ...@@ -67,14 +61,6 @@ void main() {
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('Generate Keycodes for macOS', () { test('Generate Keycodes for macOS', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'macos'; const String platform = 'macos';
final PlatformCodeGenerator codeGenerator = MacOSCodeGenerator( final PlatformCodeGenerator codeGenerator = MacOSCodeGenerator(
physicalData, physicalData,
...@@ -93,14 +79,6 @@ void main() { ...@@ -93,14 +79,6 @@ void main() {
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('Generate Keycodes for iOS', () { test('Generate Keycodes for iOS', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'ios'; const String platform = 'ios';
final PlatformCodeGenerator codeGenerator = IOSCodeGenerator( final PlatformCodeGenerator codeGenerator = IOSCodeGenerator(
physicalData, physicalData,
...@@ -120,14 +98,6 @@ void main() { ...@@ -120,14 +98,6 @@ void main() {
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('Generate Keycodes for Windows', () { test('Generate Keycodes for Windows', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'windows'; const String platform = 'windows';
final PlatformCodeGenerator codeGenerator = WindowsCodeGenerator( final PlatformCodeGenerator codeGenerator = WindowsCodeGenerator(
physicalData, physicalData,
...@@ -143,14 +113,6 @@ void main() { ...@@ -143,14 +113,6 @@ void main() {
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('Generate Keycodes for Linux', () { test('Generate Keycodes for Linux', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'gtk'; const String platform = 'gtk';
final PlatformCodeGenerator codeGenerator = GtkCodeGenerator( final PlatformCodeGenerator codeGenerator = GtkCodeGenerator(
physicalData, physicalData,
...@@ -166,14 +128,6 @@ void main() { ...@@ -166,14 +128,6 @@ void main() {
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('Generate Keycodes for Web', () { test('Generate Keycodes for Web', () {
PhysicalKeyData physicalData;
LogicalKeyData logicalData;
physicalData = PhysicalKeyData.fromJson(
json.decode(File(testPhysicalData).readAsStringSync()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(
json.decode(File(testLogicalData).readAsStringSync()) as Map<String, dynamic>);
const String platform = 'web'; const String platform = 'web';
final PlatformCodeGenerator codeGenerator = WebCodeGenerator( final PlatformCodeGenerator codeGenerator = WebCodeGenerator(
physicalData, physicalData,
...@@ -188,4 +142,25 @@ void main() { ...@@ -188,4 +142,25 @@ void main() {
expect(output, contains('kWebLogicalLocationMap')); expect(output, contains('kWebLogicalLocationMap'));
checkCommonOutput(output); checkCommonOutput(output);
}); });
test('LogicalKeyData', () async {
final List<LogicalKeyEntry> entries = logicalData.entries.toList();
// Regression tests for https://github.com/flutter/flutter/pull/87098
expect(
entries.indexWhere((LogicalKeyEntry entry) => entry.name == 'ShiftLeft'),
isNot(-1));
expect(
entries.indexWhere((LogicalKeyEntry entry) => entry.webNames.contains('ShiftLeft')),
-1);
// 'Shift' maps to both 'ShiftLeft' and 'ShiftRight', and should be resolved
// by other ways.
expect(
entries.indexWhere((LogicalKeyEntry entry) => entry.webNames.contains('Shift')),
-1);
// Printable keys must not be added with Web key of their names.
expect(
entries.indexWhere((LogicalKeyEntry entry) => entry.webNames.contains('Slash')),
-1);
});
} }
...@@ -2141,25 +2141,17 @@ const Map<int, PhysicalKeyboardKey> kLinuxToPhysicalKey = <int, PhysicalKeyboard ...@@ -2141,25 +2141,17 @@ const Map<int, PhysicalKeyboardKey> kLinuxToPhysicalKey = <int, PhysicalKeyboard
const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboardKey>{ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboardKey>{
'AVRInput': LogicalKeyboardKey.avrInput, 'AVRInput': LogicalKeyboardKey.avrInput,
'AVRPower': LogicalKeyboardKey.avrPower, 'AVRPower': LogicalKeyboardKey.avrPower,
'Abort': LogicalKeyboardKey.abort,
'Accel': LogicalKeyboardKey.accel, 'Accel': LogicalKeyboardKey.accel,
'Accept': LogicalKeyboardKey.accept, 'Accept': LogicalKeyboardKey.accept,
'Add': LogicalKeyboardKey.add,
'Again': LogicalKeyboardKey.again, 'Again': LogicalKeyboardKey.again,
'AllCandidates': LogicalKeyboardKey.allCandidates, 'AllCandidates': LogicalKeyboardKey.allCandidates,
'Alphanumeric': LogicalKeyboardKey.alphanumeric, 'Alphanumeric': LogicalKeyboardKey.alphanumeric,
'Alt': LogicalKeyboardKey.alt,
'AltGraph': LogicalKeyboardKey.altGraph, 'AltGraph': LogicalKeyboardKey.altGraph,
'AltLeft': LogicalKeyboardKey.altLeft,
'AltRight': LogicalKeyboardKey.altRight,
'Ampersand': LogicalKeyboardKey.ampersand,
'AppSwitch': LogicalKeyboardKey.appSwitch, 'AppSwitch': LogicalKeyboardKey.appSwitch,
'ArrowDown': LogicalKeyboardKey.arrowDown, 'ArrowDown': LogicalKeyboardKey.arrowDown,
'ArrowLeft': LogicalKeyboardKey.arrowLeft, 'ArrowLeft': LogicalKeyboardKey.arrowLeft,
'ArrowRight': LogicalKeyboardKey.arrowRight, 'ArrowRight': LogicalKeyboardKey.arrowRight,
'ArrowUp': LogicalKeyboardKey.arrowUp, 'ArrowUp': LogicalKeyboardKey.arrowUp,
'Asterisk': LogicalKeyboardKey.asterisk,
'At': LogicalKeyboardKey.at,
'Attn': LogicalKeyboardKey.attn, 'Attn': LogicalKeyboardKey.attn,
'AudioBalanceLeft': LogicalKeyboardKey.audioBalanceLeft, 'AudioBalanceLeft': LogicalKeyboardKey.audioBalanceLeft,
'AudioBalanceRight': LogicalKeyboardKey.audioBalanceRight, 'AudioBalanceRight': LogicalKeyboardKey.audioBalanceRight,
...@@ -2174,14 +2166,7 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2174,14 +2166,7 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'AudioVolumeDown': LogicalKeyboardKey.audioVolumeDown, 'AudioVolumeDown': LogicalKeyboardKey.audioVolumeDown,
'AudioVolumeMute': LogicalKeyboardKey.audioVolumeMute, 'AudioVolumeMute': LogicalKeyboardKey.audioVolumeMute,
'AudioVolumeUp': LogicalKeyboardKey.audioVolumeUp, 'AudioVolumeUp': LogicalKeyboardKey.audioVolumeUp,
'Backquote': LogicalKeyboardKey.backquote,
'Backslash': LogicalKeyboardKey.backslash,
'Backspace': LogicalKeyboardKey.backspace, 'Backspace': LogicalKeyboardKey.backspace,
'Bar': LogicalKeyboardKey.bar,
'BraceLeft': LogicalKeyboardKey.braceLeft,
'BraceRight': LogicalKeyboardKey.braceRight,
'BracketLeft': LogicalKeyboardKey.bracketLeft,
'BracketRight': LogicalKeyboardKey.bracketRight,
'BrightnessDown': LogicalKeyboardKey.brightnessDown, 'BrightnessDown': LogicalKeyboardKey.brightnessDown,
'BrightnessUp': LogicalKeyboardKey.brightnessUp, 'BrightnessUp': LogicalKeyboardKey.brightnessUp,
'BrowserBack': LogicalKeyboardKey.browserBack, 'BrowserBack': LogicalKeyboardKey.browserBack,
...@@ -2196,55 +2181,36 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2196,55 +2181,36 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'CameraFocus': LogicalKeyboardKey.cameraFocus, 'CameraFocus': LogicalKeyboardKey.cameraFocus,
'Cancel': LogicalKeyboardKey.cancel, 'Cancel': LogicalKeyboardKey.cancel,
'CapsLock': LogicalKeyboardKey.capsLock, 'CapsLock': LogicalKeyboardKey.capsLock,
'Caret': LogicalKeyboardKey.caret,
'ChannelDown': LogicalKeyboardKey.channelDown, 'ChannelDown': LogicalKeyboardKey.channelDown,
'ChannelUp': LogicalKeyboardKey.channelUp, 'ChannelUp': LogicalKeyboardKey.channelUp,
'Clear': LogicalKeyboardKey.clear, 'Clear': LogicalKeyboardKey.clear,
'Close': LogicalKeyboardKey.close, 'Close': LogicalKeyboardKey.close,
'ClosedCaptionToggle': LogicalKeyboardKey.closedCaptionToggle, 'ClosedCaptionToggle': LogicalKeyboardKey.closedCaptionToggle,
'CodeInput': LogicalKeyboardKey.codeInput, 'CodeInput': LogicalKeyboardKey.codeInput,
'Colon': LogicalKeyboardKey.colon,
'ColorF0Red': LogicalKeyboardKey.colorF0Red, 'ColorF0Red': LogicalKeyboardKey.colorF0Red,
'ColorF1Green': LogicalKeyboardKey.colorF1Green, 'ColorF1Green': LogicalKeyboardKey.colorF1Green,
'ColorF2Yellow': LogicalKeyboardKey.colorF2Yellow, 'ColorF2Yellow': LogicalKeyboardKey.colorF2Yellow,
'ColorF3Blue': LogicalKeyboardKey.colorF3Blue, 'ColorF3Blue': LogicalKeyboardKey.colorF3Blue,
'ColorF4Grey': LogicalKeyboardKey.colorF4Grey, 'ColorF4Grey': LogicalKeyboardKey.colorF4Grey,
'ColorF5Brown': LogicalKeyboardKey.colorF5Brown, 'ColorF5Brown': LogicalKeyboardKey.colorF5Brown,
'Comma': LogicalKeyboardKey.comma,
'Compose': LogicalKeyboardKey.compose, 'Compose': LogicalKeyboardKey.compose,
'ContextMenu': LogicalKeyboardKey.contextMenu, 'ContextMenu': LogicalKeyboardKey.contextMenu,
'Control': LogicalKeyboardKey.control,
'ControlLeft': LogicalKeyboardKey.controlLeft,
'ControlRight': LogicalKeyboardKey.controlRight,
'Convert': LogicalKeyboardKey.convert, 'Convert': LogicalKeyboardKey.convert,
'Copy': LogicalKeyboardKey.copy, 'Copy': LogicalKeyboardKey.copy,
'CrSel': LogicalKeyboardKey.crSel, 'CrSel': LogicalKeyboardKey.crSel,
'Cut': LogicalKeyboardKey.cut, 'Cut': LogicalKeyboardKey.cut,
'DVR': LogicalKeyboardKey.dvr, 'DVR': LogicalKeyboardKey.dvr,
'Delete': LogicalKeyboardKey.delete, 'Delete': LogicalKeyboardKey.delete,
'Digit0': LogicalKeyboardKey.digit0,
'Digit1': LogicalKeyboardKey.digit1,
'Digit2': LogicalKeyboardKey.digit2,
'Digit3': LogicalKeyboardKey.digit3,
'Digit4': LogicalKeyboardKey.digit4,
'Digit5': LogicalKeyboardKey.digit5,
'Digit6': LogicalKeyboardKey.digit6,
'Digit7': LogicalKeyboardKey.digit7,
'Digit8': LogicalKeyboardKey.digit8,
'Digit9': LogicalKeyboardKey.digit9,
'Dimmer': LogicalKeyboardKey.dimmer, 'Dimmer': LogicalKeyboardKey.dimmer,
'DisplaySwap': LogicalKeyboardKey.displaySwap, 'DisplaySwap': LogicalKeyboardKey.displaySwap,
'Dollar': LogicalKeyboardKey.dollar,
'Eisu': LogicalKeyboardKey.eisu, 'Eisu': LogicalKeyboardKey.eisu,
'Eject': LogicalKeyboardKey.eject, 'Eject': LogicalKeyboardKey.eject,
'End': LogicalKeyboardKey.end, 'End': LogicalKeyboardKey.end,
'EndCall': LogicalKeyboardKey.endCall, 'EndCall': LogicalKeyboardKey.endCall,
'Enter': LogicalKeyboardKey.enter, 'Enter': LogicalKeyboardKey.enter,
'Equal': LogicalKeyboardKey.equal,
'EraseEof': LogicalKeyboardKey.eraseEof, 'EraseEof': LogicalKeyboardKey.eraseEof,
'Escape': LogicalKeyboardKey.escape, 'Escape': LogicalKeyboardKey.escape,
'ExSel': LogicalKeyboardKey.exSel, 'ExSel': LogicalKeyboardKey.exSel,
'Exclamation': LogicalKeyboardKey.exclamation,
'Execute': LogicalKeyboardKey.execute, 'Execute': LogicalKeyboardKey.execute,
'Exit': LogicalKeyboardKey.exit, 'Exit': LogicalKeyboardKey.exit,
'F1': LogicalKeyboardKey.f1, 'F1': LogicalKeyboardKey.f1,
...@@ -2287,40 +2253,8 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2287,40 +2253,8 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'Find': LogicalKeyboardKey.find, 'Find': LogicalKeyboardKey.find,
'Fn': LogicalKeyboardKey.fn, 'Fn': LogicalKeyboardKey.fn,
'FnLock': LogicalKeyboardKey.fnLock, 'FnLock': LogicalKeyboardKey.fnLock,
'GameButton1': LogicalKeyboardKey.gameButton1,
'GameButton10': LogicalKeyboardKey.gameButton10,
'GameButton11': LogicalKeyboardKey.gameButton11,
'GameButton12': LogicalKeyboardKey.gameButton12,
'GameButton13': LogicalKeyboardKey.gameButton13,
'GameButton14': LogicalKeyboardKey.gameButton14,
'GameButton15': LogicalKeyboardKey.gameButton15,
'GameButton16': LogicalKeyboardKey.gameButton16,
'GameButton2': LogicalKeyboardKey.gameButton2,
'GameButton3': LogicalKeyboardKey.gameButton3,
'GameButton4': LogicalKeyboardKey.gameButton4,
'GameButton5': LogicalKeyboardKey.gameButton5,
'GameButton6': LogicalKeyboardKey.gameButton6,
'GameButton7': LogicalKeyboardKey.gameButton7,
'GameButton8': LogicalKeyboardKey.gameButton8,
'GameButton9': LogicalKeyboardKey.gameButton9,
'GameButtonA': LogicalKeyboardKey.gameButtonA,
'GameButtonB': LogicalKeyboardKey.gameButtonB,
'GameButtonC': LogicalKeyboardKey.gameButtonC,
'GameButtonLeft1': LogicalKeyboardKey.gameButtonLeft1,
'GameButtonLeft2': LogicalKeyboardKey.gameButtonLeft2,
'GameButtonMode': LogicalKeyboardKey.gameButtonMode,
'GameButtonRight1': LogicalKeyboardKey.gameButtonRight1,
'GameButtonRight2': LogicalKeyboardKey.gameButtonRight2,
'GameButtonSelect': LogicalKeyboardKey.gameButtonSelect,
'GameButtonStart': LogicalKeyboardKey.gameButtonStart,
'GameButtonThumbLeft': LogicalKeyboardKey.gameButtonThumbLeft,
'GameButtonThumbRight': LogicalKeyboardKey.gameButtonThumbRight,
'GameButtonX': LogicalKeyboardKey.gameButtonX,
'GameButtonY': LogicalKeyboardKey.gameButtonY,
'GameButtonZ': LogicalKeyboardKey.gameButtonZ,
'GoBack': LogicalKeyboardKey.goBack, 'GoBack': LogicalKeyboardKey.goBack,
'GoHome': LogicalKeyboardKey.goHome, 'GoHome': LogicalKeyboardKey.goHome,
'Greater': LogicalKeyboardKey.greater,
'GroupFirst': LogicalKeyboardKey.groupFirst, 'GroupFirst': LogicalKeyboardKey.groupFirst,
'GroupLast': LogicalKeyboardKey.groupLast, 'GroupLast': LogicalKeyboardKey.groupLast,
'GroupNext': LogicalKeyboardKey.groupNext, 'GroupNext': LogicalKeyboardKey.groupNext,
...@@ -2341,46 +2275,12 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2341,46 +2275,12 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'Info': LogicalKeyboardKey.info, 'Info': LogicalKeyboardKey.info,
'Insert': LogicalKeyboardKey.insert, 'Insert': LogicalKeyboardKey.insert,
'InstantReplay': LogicalKeyboardKey.instantReplay, 'InstantReplay': LogicalKeyboardKey.instantReplay,
'IntlBackslash': LogicalKeyboardKey.intlBackslash,
'IntlRo': LogicalKeyboardKey.intlRo,
'IntlYen': LogicalKeyboardKey.intlYen,
'JunjaMode': LogicalKeyboardKey.junjaMode, 'JunjaMode': LogicalKeyboardKey.junjaMode,
'KanaMode': LogicalKeyboardKey.kanaMode, 'KanaMode': LogicalKeyboardKey.kanaMode,
'KanjiMode': LogicalKeyboardKey.kanjiMode, 'KanjiMode': LogicalKeyboardKey.kanjiMode,
'Katakana': LogicalKeyboardKey.katakana, 'Katakana': LogicalKeyboardKey.katakana,
'Key11': LogicalKeyboardKey.key11, 'Key11': LogicalKeyboardKey.key11,
'Key12': LogicalKeyboardKey.key12, 'Key12': LogicalKeyboardKey.key12,
'KeyA': LogicalKeyboardKey.keyA,
'KeyB': LogicalKeyboardKey.keyB,
'KeyC': LogicalKeyboardKey.keyC,
'KeyD': LogicalKeyboardKey.keyD,
'KeyE': LogicalKeyboardKey.keyE,
'KeyF': LogicalKeyboardKey.keyF,
'KeyG': LogicalKeyboardKey.keyG,
'KeyH': LogicalKeyboardKey.keyH,
'KeyI': LogicalKeyboardKey.keyI,
'KeyJ': LogicalKeyboardKey.keyJ,
'KeyK': LogicalKeyboardKey.keyK,
'KeyL': LogicalKeyboardKey.keyL,
'KeyM': LogicalKeyboardKey.keyM,
'KeyN': LogicalKeyboardKey.keyN,
'KeyO': LogicalKeyboardKey.keyO,
'KeyP': LogicalKeyboardKey.keyP,
'KeyQ': LogicalKeyboardKey.keyQ,
'KeyR': LogicalKeyboardKey.keyR,
'KeyS': LogicalKeyboardKey.keyS,
'KeyT': LogicalKeyboardKey.keyT,
'KeyU': LogicalKeyboardKey.keyU,
'KeyV': LogicalKeyboardKey.keyV,
'KeyW': LogicalKeyboardKey.keyW,
'KeyX': LogicalKeyboardKey.keyX,
'KeyY': LogicalKeyboardKey.keyY,
'KeyZ': LogicalKeyboardKey.keyZ,
'Lang1': LogicalKeyboardKey.lang1,
'Lang2': LogicalKeyboardKey.lang2,
'Lang3': LogicalKeyboardKey.lang3,
'Lang4': LogicalKeyboardKey.lang4,
'Lang5': LogicalKeyboardKey.lang5,
'LastNumberRedial': LogicalKeyboardKey.lastNumberRedial, 'LastNumberRedial': LogicalKeyboardKey.lastNumberRedial,
'LaunchApplication1': LogicalKeyboardKey.launchApplication1, 'LaunchApplication1': LogicalKeyboardKey.launchApplication1,
'LaunchApplication2': LogicalKeyboardKey.launchApplication2, 'LaunchApplication2': LogicalKeyboardKey.launchApplication2,
...@@ -2397,7 +2297,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2397,7 +2297,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'LaunchWebBrowser': LogicalKeyboardKey.launchWebBrowser, 'LaunchWebBrowser': LogicalKeyboardKey.launchWebBrowser,
'LaunchWebCam': LogicalKeyboardKey.launchWebCam, 'LaunchWebCam': LogicalKeyboardKey.launchWebCam,
'LaunchWordProcessor': LogicalKeyboardKey.launchWordProcessor, 'LaunchWordProcessor': LogicalKeyboardKey.launchWordProcessor,
'Less': LogicalKeyboardKey.less,
'Link': LogicalKeyboardKey.link, 'Link': LogicalKeyboardKey.link,
'ListProgram': LogicalKeyboardKey.listProgram, 'ListProgram': LogicalKeyboardKey.listProgram,
'LiveContent': LogicalKeyboardKey.liveContent, 'LiveContent': LogicalKeyboardKey.liveContent,
...@@ -2426,14 +2325,10 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2426,14 +2325,10 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'MediaTopMenu': LogicalKeyboardKey.mediaTopMenu, 'MediaTopMenu': LogicalKeyboardKey.mediaTopMenu,
'MediaTrackNext': LogicalKeyboardKey.mediaTrackNext, 'MediaTrackNext': LogicalKeyboardKey.mediaTrackNext,
'MediaTrackPrevious': LogicalKeyboardKey.mediaTrackPrevious, 'MediaTrackPrevious': LogicalKeyboardKey.mediaTrackPrevious,
'Meta': LogicalKeyboardKey.meta,
'MetaLeft': LogicalKeyboardKey.metaLeft,
'MetaRight': LogicalKeyboardKey.metaRight,
'MicrophoneToggle': LogicalKeyboardKey.microphoneToggle, 'MicrophoneToggle': LogicalKeyboardKey.microphoneToggle,
'MicrophoneVolumeDown': LogicalKeyboardKey.microphoneVolumeDown, 'MicrophoneVolumeDown': LogicalKeyboardKey.microphoneVolumeDown,
'MicrophoneVolumeMute': LogicalKeyboardKey.microphoneVolumeMute, 'MicrophoneVolumeMute': LogicalKeyboardKey.microphoneVolumeMute,
'MicrophoneVolumeUp': LogicalKeyboardKey.microphoneVolumeUp, 'MicrophoneVolumeUp': LogicalKeyboardKey.microphoneVolumeUp,
'Minus': LogicalKeyboardKey.minus,
'ModeChange': LogicalKeyboardKey.modeChange, 'ModeChange': LogicalKeyboardKey.modeChange,
'NavigateIn': LogicalKeyboardKey.navigateIn, 'NavigateIn': LogicalKeyboardKey.navigateIn,
'NavigateNext': LogicalKeyboardKey.navigateNext, 'NavigateNext': LogicalKeyboardKey.navigateNext,
...@@ -2446,38 +2341,13 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2446,38 +2341,13 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'NonConvert': LogicalKeyboardKey.nonConvert, 'NonConvert': LogicalKeyboardKey.nonConvert,
'Notification': LogicalKeyboardKey.notification, 'Notification': LogicalKeyboardKey.notification,
'NumLock': LogicalKeyboardKey.numLock, 'NumLock': LogicalKeyboardKey.numLock,
'NumberSign': LogicalKeyboardKey.numberSign,
'Numpad0': LogicalKeyboardKey.numpad0,
'Numpad1': LogicalKeyboardKey.numpad1,
'Numpad2': LogicalKeyboardKey.numpad2,
'Numpad3': LogicalKeyboardKey.numpad3,
'Numpad4': LogicalKeyboardKey.numpad4,
'Numpad5': LogicalKeyboardKey.numpad5,
'Numpad6': LogicalKeyboardKey.numpad6,
'Numpad7': LogicalKeyboardKey.numpad7,
'Numpad8': LogicalKeyboardKey.numpad8,
'Numpad9': LogicalKeyboardKey.numpad9,
'NumpadAdd': LogicalKeyboardKey.numpadAdd,
'NumpadComma': LogicalKeyboardKey.numpadComma,
'NumpadDecimal': LogicalKeyboardKey.numpadDecimal,
'NumpadDivide': LogicalKeyboardKey.numpadDivide,
'NumpadEnter': LogicalKeyboardKey.numpadEnter,
'NumpadEqual': LogicalKeyboardKey.numpadEqual,
'NumpadMultiply': LogicalKeyboardKey.numpadMultiply,
'NumpadParenLeft': LogicalKeyboardKey.numpadParenLeft,
'NumpadParenRight': LogicalKeyboardKey.numpadParenRight,
'NumpadSubtract': LogicalKeyboardKey.numpadSubtract,
'OnDemand': LogicalKeyboardKey.onDemand, 'OnDemand': LogicalKeyboardKey.onDemand,
'Open': LogicalKeyboardKey.open, 'Open': LogicalKeyboardKey.open,
'PageDown': LogicalKeyboardKey.pageDown, 'PageDown': LogicalKeyboardKey.pageDown,
'PageUp': LogicalKeyboardKey.pageUp, 'PageUp': LogicalKeyboardKey.pageUp,
'Pairing': LogicalKeyboardKey.pairing, 'Pairing': LogicalKeyboardKey.pairing,
'ParenthesisLeft': LogicalKeyboardKey.parenthesisLeft,
'ParenthesisRight': LogicalKeyboardKey.parenthesisRight,
'Paste': LogicalKeyboardKey.paste, 'Paste': LogicalKeyboardKey.paste,
'Pause': LogicalKeyboardKey.pause, 'Pause': LogicalKeyboardKey.pause,
'Percent': LogicalKeyboardKey.percent,
'Period': LogicalKeyboardKey.period,
'PinPDown': LogicalKeyboardKey.pInPDown, 'PinPDown': LogicalKeyboardKey.pInPDown,
'PinPMove': LogicalKeyboardKey.pInPMove, 'PinPMove': LogicalKeyboardKey.pInPMove,
'PinPToggle': LogicalKeyboardKey.pInPToggle, 'PinPToggle': LogicalKeyboardKey.pInPToggle,
...@@ -2493,14 +2363,10 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2493,14 +2363,10 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'PrintScreen': LogicalKeyboardKey.printScreen, 'PrintScreen': LogicalKeyboardKey.printScreen,
'Process': LogicalKeyboardKey.process, 'Process': LogicalKeyboardKey.process,
'Props': LogicalKeyboardKey.props, 'Props': LogicalKeyboardKey.props,
'Question': LogicalKeyboardKey.question,
'Quote': LogicalKeyboardKey.quote,
'QuoteSingle': LogicalKeyboardKey.quoteSingle,
'RandomToggle': LogicalKeyboardKey.randomToggle, 'RandomToggle': LogicalKeyboardKey.randomToggle,
'RcLowBattery': LogicalKeyboardKey.rcLowBattery, 'RcLowBattery': LogicalKeyboardKey.rcLowBattery,
'RecordSpeedNext': LogicalKeyboardKey.recordSpeedNext, 'RecordSpeedNext': LogicalKeyboardKey.recordSpeedNext,
'Redo': LogicalKeyboardKey.redo, 'Redo': LogicalKeyboardKey.redo,
'Resume': LogicalKeyboardKey.resume,
'RfBypass': LogicalKeyboardKey.rfBypass, 'RfBypass': LogicalKeyboardKey.rfBypass,
'Romaji': LogicalKeyboardKey.romaji, 'Romaji': LogicalKeyboardKey.romaji,
'STBInput': LogicalKeyboardKey.stbInput, 'STBInput': LogicalKeyboardKey.stbInput,
...@@ -2510,15 +2376,9 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2510,15 +2376,9 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'ScreenModeNext': LogicalKeyboardKey.screenModeNext, 'ScreenModeNext': LogicalKeyboardKey.screenModeNext,
'ScrollLock': LogicalKeyboardKey.scrollLock, 'ScrollLock': LogicalKeyboardKey.scrollLock,
'Select': LogicalKeyboardKey.select, 'Select': LogicalKeyboardKey.select,
'Semicolon': LogicalKeyboardKey.semicolon,
'Settings': LogicalKeyboardKey.settings, 'Settings': LogicalKeyboardKey.settings,
'Shift': LogicalKeyboardKey.shift,
'ShiftLeft': LogicalKeyboardKey.shiftLeft,
'ShiftLevel5': LogicalKeyboardKey.shiftLevel5, 'ShiftLevel5': LogicalKeyboardKey.shiftLevel5,
'ShiftRight': LogicalKeyboardKey.shiftRight,
'SingleCandidate': LogicalKeyboardKey.singleCandidate, 'SingleCandidate': LogicalKeyboardKey.singleCandidate,
'Slash': LogicalKeyboardKey.slash,
'Sleep': LogicalKeyboardKey.sleep,
'Soft1': LogicalKeyboardKey.soft1, 'Soft1': LogicalKeyboardKey.soft1,
'Soft2': LogicalKeyboardKey.soft2, 'Soft2': LogicalKeyboardKey.soft2,
'Soft3': LogicalKeyboardKey.soft3, 'Soft3': LogicalKeyboardKey.soft3,
...@@ -2527,7 +2387,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2527,7 +2387,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'Soft6': LogicalKeyboardKey.soft6, 'Soft6': LogicalKeyboardKey.soft6,
'Soft7': LogicalKeyboardKey.soft7, 'Soft7': LogicalKeyboardKey.soft7,
'Soft8': LogicalKeyboardKey.soft8, 'Soft8': LogicalKeyboardKey.soft8,
'Space': LogicalKeyboardKey.space,
'SpeechCorrectionList': LogicalKeyboardKey.speechCorrectionList, 'SpeechCorrectionList': LogicalKeyboardKey.speechCorrectionList,
'SpeechInputToggle': LogicalKeyboardKey.speechInputToggle, 'SpeechInputToggle': LogicalKeyboardKey.speechInputToggle,
'SpellCheck': LogicalKeyboardKey.spellCheck, 'SpellCheck': LogicalKeyboardKey.spellCheck,
...@@ -2535,7 +2394,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2535,7 +2394,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'Standby': LogicalKeyboardKey.standby, 'Standby': LogicalKeyboardKey.standby,
'Subtitle': LogicalKeyboardKey.subtitle, 'Subtitle': LogicalKeyboardKey.subtitle,
'Super': LogicalKeyboardKey.superKey, 'Super': LogicalKeyboardKey.superKey,
'Suspend': LogicalKeyboardKey.suspend,
'Symbol': LogicalKeyboardKey.symbol, 'Symbol': LogicalKeyboardKey.symbol,
'SymbolLock': LogicalKeyboardKey.symbolLock, 'SymbolLock': LogicalKeyboardKey.symbolLock,
'TV': LogicalKeyboardKey.tv, 'TV': LogicalKeyboardKey.tv,
...@@ -2570,8 +2428,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar ...@@ -2570,8 +2428,6 @@ const Map<String, LogicalKeyboardKey> kWebToLogicalKey = <String, LogicalKeyboar
'TVTimer': LogicalKeyboardKey.tvTimer, 'TVTimer': LogicalKeyboardKey.tvTimer,
'Tab': LogicalKeyboardKey.tab, 'Tab': LogicalKeyboardKey.tab,
'Teletext': LogicalKeyboardKey.teletext, 'Teletext': LogicalKeyboardKey.teletext,
'Tilde': LogicalKeyboardKey.tilde,
'Underscore': LogicalKeyboardKey.underscore,
'Undo': LogicalKeyboardKey.undo, 'Undo': LogicalKeyboardKey.undo,
'Unidentified': LogicalKeyboardKey.unidentified, 'Unidentified': LogicalKeyboardKey.unidentified,
'VideoModeNext': LogicalKeyboardKey.videoModeNext, 'VideoModeNext': LogicalKeyboardKey.videoModeNext,
......
...@@ -285,12 +285,10 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -285,12 +285,10 @@ abstract class RawKeyEvent with Diagnosticable {
/// Creates a concrete [RawKeyEvent] class from a message in the form received /// Creates a concrete [RawKeyEvent] class from a message in the form received
/// on the [SystemChannels.keyEvent] channel. /// on the [SystemChannels.keyEvent] channel.
factory RawKeyEvent.fromMessage(Map<String, dynamic> message) { factory RawKeyEvent.fromMessage(Map<String, dynamic> message) {
final RawKeyEventData data;
String? character; String? character;
RawKeyEventData _dataFromWeb() { RawKeyEventData _dataFromWeb() {
final String? key = message['key'] as String?; final String? key = message['key'] as String?;
if (key != null && key.isNotEmpty) { if (key != null && key.isNotEmpty && key.length == 1) {
character = key; character = key;
} }
return RawKeyEventDataWeb( return RawKeyEventDataWeb(
...@@ -300,6 +298,8 @@ abstract class RawKeyEvent with Diagnosticable { ...@@ -300,6 +298,8 @@ abstract class RawKeyEvent with Diagnosticable {
metaState: message['metaState'] as int? ?? 0, metaState: message['metaState'] as int? ?? 0,
); );
} }
final RawKeyEventData data;
if (kIsWeb) { if (kIsWeb) {
data = _dataFromWeb(); data = _dataFromWeb();
} else { } else {
......
...@@ -10,6 +10,13 @@ import 'keyboard_key.dart'; ...@@ -10,6 +10,13 @@ import 'keyboard_key.dart';
import 'keyboard_maps.dart'; import 'keyboard_maps.dart';
import 'raw_keyboard.dart'; import 'raw_keyboard.dart';
String? _unicodeChar(String key) {
if (key.length == 1) {
return key.substring(0, 1);
}
return null;
}
/// Platform-specific key event data for Web. /// Platform-specific key event data for Web.
/// ///
/// See also: /// See also:
...@@ -74,7 +81,7 @@ class RawKeyEventDataWeb extends RawKeyEventData { ...@@ -74,7 +81,7 @@ class RawKeyEventDataWeb extends RawKeyEventData {
final int metaState; final int metaState;
@override @override
String get keyLabel => key == 'Unidentified' ? '' : key; String get keyLabel => key == 'Unidentified' ? '' : _unicodeChar(key) ?? '';
@override @override
PhysicalKeyboardKey get physicalKey { PhysicalKeyboardKey get physicalKey {
...@@ -95,9 +102,14 @@ class RawKeyEventDataWeb extends RawKeyEventData { ...@@ -95,9 +102,14 @@ class RawKeyEventDataWeb extends RawKeyEventData {
return newKey; return newKey;
} }
final bool isPrintable = key.length == 1;
if (isPrintable)
return LogicalKeyboardKey(key.codeUnitAt(0));
// This is a non-printable key that we don't know about, so we mint a new // This is a non-printable key that we don't know about, so we mint a new
// code. // key from `code`. Don't mint with `key`, because the `key` will always be
return LogicalKeyboardKey(code.hashCode | LogicalKeyboardKey.webPlane); // "Unidentified" .
return LogicalKeyboardKey(code.hashCode + LogicalKeyboardKey.webPlane);
} }
@override @override
......
...@@ -2400,6 +2400,7 @@ void main() { ...@@ -2400,6 +2400,7 @@ void main() {
'keymap': 'web', 'keymap': 'web',
'code': 'KeyA', 'code': 'KeyA',
'key': 'a', 'key': 'a',
'location': 0,
'metaState': 0x0, 'metaState': 0x0,
}); });
final RawKeyEventDataWeb data = keyAEvent.data as RawKeyEventDataWeb; final RawKeyEventDataWeb data = keyAEvent.data as RawKeyEventDataWeb;
...@@ -2413,6 +2414,8 @@ void main() { ...@@ -2413,6 +2414,8 @@ void main() {
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'Escape', 'code': 'Escape',
'key': 'Escape',
'location': 0,
'metaState': 0x0, 'metaState': 0x0,
}); });
final RawKeyEventDataWeb data = escapeKeyEvent.data as RawKeyEventDataWeb; final RawKeyEventDataWeb data = escapeKeyEvent.data as RawKeyEventDataWeb;
...@@ -2426,6 +2429,8 @@ void main() { ...@@ -2426,6 +2429,8 @@ void main() {
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'ShiftLeft', 'code': 'ShiftLeft',
'key': 'Shift',
'location': 1,
'metaState': RawKeyEventDataWeb.modifierShift, 'metaState': RawKeyEventDataWeb.modifierShift,
}); });
final RawKeyEventDataWeb data = shiftKeyEvent.data as RawKeyEventDataWeb; final RawKeyEventDataWeb data = shiftKeyEvent.data as RawKeyEventDataWeb;
...@@ -2439,6 +2444,8 @@ void main() { ...@@ -2439,6 +2444,8 @@ void main() {
'type': 'keydown', 'type': 'keydown',
'keymap': 'web', 'keymap': 'web',
'code': 'ArrowDown', 'code': 'ArrowDown',
'key': 'ArrowDown',
'location': 0,
'metaState': 0x0, 'metaState': 0x0,
}); });
final RawKeyEventDataWeb data = arrowKeyDown.data as RawKeyEventDataWeb; final RawKeyEventDataWeb data = arrowKeyDown.data as RawKeyEventDataWeb;
...@@ -2447,6 +2454,25 @@ void main() { ...@@ -2447,6 +2454,25 @@ void main() {
expect(data.keyLabel, isEmpty); expect(data.keyLabel, isEmpty);
}); });
test('Unrecognized keys are mapped to Web plane', () {
final RawKeyEvent arrowKeyDown = RawKeyEvent.fromMessage(const <String, dynamic>{
'type': 'keydown',
'keymap': 'web',
'code': 'Unrecog1',
'key': 'Unrecog2',
'location': 0,
'metaState': 0x0,
});
final RawKeyEventDataWeb data = arrowKeyDown.data as RawKeyEventDataWeb;
// This might be easily broken on Web if the code fails to acknowledge
// that JavaScript doesn't handle 64-bit bit-wise operation.
expect(data.physicalKey.usbHidUsage, greaterThan(0x01700000000));
expect(data.physicalKey.usbHidUsage, lessThan(0x01800000000));
expect(data.logicalKey.keyId, greaterThan(0x01700000000));
expect(data.logicalKey.keyId, lessThan(0x01800000000));
expect(data.keyLabel, isEmpty);
});
test('data.toString', () { test('data.toString', () {
expect(RawKeyEvent.fromMessage(const <String, dynamic>{ expect(RawKeyEvent.fromMessage(const <String, dynamic>{
'type': 'keydown', 'type': 'keydown',
......
...@@ -14,6 +14,16 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -14,6 +14,16 @@ import 'package:flutter_test/flutter_test.dart';
import 'binding.dart'; import 'binding.dart';
import 'test_async_utils.dart'; import 'test_async_utils.dart';
// A tuple of `key` and `location` from Web's `KeyboardEvent` class.
//
// See [RawKeyEventDataWeb]'s `key` and `location` fields for details.
@immutable
class _WebKeyLocationPair {
const _WebKeyLocationPair(this.key, this.location);
final String key;
final int location;
}
// TODO(gspencergoog): Replace this with more robust key simulation code once // TODO(gspencergoog): Replace this with more robust key simulation code once
// the new key event code is in. // the new key event code is in.
// https://github.com/flutter/flutter/issues/33521 // https://github.com/flutter/flutter/issues/33521
...@@ -145,8 +155,32 @@ class KeyEventSimulator { ...@@ -145,8 +155,32 @@ class KeyEventSimulator {
} }
} }
static String _getWebKeyCode(LogicalKeyboardKey key) { static PhysicalKeyboardKey _inferPhysicalKey(LogicalKeyboardKey key) {
PhysicalKeyboardKey? result;
for (final PhysicalKeyboardKey physicalKey in PhysicalKeyboardKey.knownPhysicalKeys) {
if (physicalKey.debugName == key.debugName) {
result = physicalKey;
break;
}
}
assert(result != null, 'Unable to infer physical key for $key');
return result!;
}
static _WebKeyLocationPair _getWebKeyLocation(LogicalKeyboardKey key, String keyLabel) {
String? result; String? result;
for (final MapEntry<String, List<LogicalKeyboardKey?>> entry in kWebLocationMap.entries) {
final int foundIndex = entry.value.indexOf(key);
// If foundIndex is -1, then the key is not defined in kWebLocationMap.
// If foundIndex is 0, then the key is in the standard part of the keyboard,
// but we have to check `keyLabel` to see if it's remapped or modified.
if (foundIndex != -1 && foundIndex != 0) {
return _WebKeyLocationPair(entry.key, foundIndex);
}
}
if (keyLabel.isNotEmpty) {
return _WebKeyLocationPair(keyLabel, 0);
}
for (final String code in kWebToLogicalKey.keys) { for (final String code in kWebToLogicalKey.keys) {
if (key.keyId == kWebToLogicalKey[code]!.keyId) { if (key.keyId == kWebToLogicalKey[code]!.keyId) {
result = code; result = code;
...@@ -154,6 +188,18 @@ class KeyEventSimulator { ...@@ -154,6 +188,18 @@ class KeyEventSimulator {
} }
} }
assert(result != null, 'Key $key not found in web keyCode map'); assert(result != null, 'Key $key not found in web keyCode map');
return _WebKeyLocationPair(result!, 0);
}
static String _getWebCode(PhysicalKeyboardKey key) {
String? result;
for (final MapEntry<String, PhysicalKeyboardKey> entry in kWebToPhysicalKey.entries) {
if (entry.value.usbHidUsage == key.usbHidUsage) {
result = entry.key;
break;
}
}
assert(result != null, 'Key $key not found in web code map');
return result!; return result!;
} }
...@@ -215,8 +261,6 @@ class KeyEventSimulator { ...@@ -215,8 +261,6 @@ class KeyEventSimulator {
physicalKey ??= _findPhysicalKeyByPlatform(key, platform); physicalKey ??= _findPhysicalKeyByPlatform(key, platform);
assert(key.debugName != null); assert(key.debugName != null);
final int keyCode = _getKeyCode(key, platform);
final int scanCode = _getScanCode(physicalKey, platform);
final Map<String, dynamic> result = <String, dynamic>{ final Map<String, dynamic> result = <String, dynamic>{
'type': isDown ? 'keydown' : 'keyup', 'type': isDown ? 'keydown' : 'keyup',
...@@ -225,14 +269,19 @@ class KeyEventSimulator { ...@@ -225,14 +269,19 @@ class KeyEventSimulator {
final String resultCharacter = character ?? _keyLabel(key) ?? ''; final String resultCharacter = character ?? _keyLabel(key) ?? '';
void assignWeb() { void assignWeb() {
result['code'] = _getWebKeyCode(key); final _WebKeyLocationPair keyLocation = _getWebKeyLocation(key, resultCharacter);
result['key'] = resultCharacter; final PhysicalKeyboardKey actualPhysicalKey = physicalKey ?? _inferPhysicalKey(key);
result['code'] = _getWebCode(actualPhysicalKey);
result['key'] = keyLocation.key;
result['location'] = keyLocation.location;
result['metaState'] = _getWebModifierFlags(key, isDown); result['metaState'] = _getWebModifierFlags(key, isDown);
} }
if (kIsWeb) { if (kIsWeb) {
assignWeb(); assignWeb();
return result; return result;
} }
final int keyCode = _getKeyCode(key, platform);
final int scanCode = _getScanCode(physicalKey, platform);
switch (platform) { switch (platform) {
case 'android': case 'android':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment