Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
13bf7515
Unverified
Commit
13bf7515
authored
Mar 16, 2022
by
moko256
Committed by
GitHub
Mar 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Web: treat modifier key without location (#98460)
parent
301822f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
9 deletions
+30
-9
web_logical_location_mapping.json
...tools/gen_keycodes/data/web_logical_location_mapping.json
+4
-4
keyboard_maps.dart
packages/flutter/lib/src/services/keyboard_maps.dart
+4
-4
raw_keyboard_test.dart
packages/flutter/test/services/raw_keyboard_test.dart
+21
-0
event_simulation.dart
packages/flutter_test/lib/src/event_simulation.dart
+1
-1
No files found.
dev/tools/gen_keycodes/data/web_logical_location_mapping.json
View file @
13bf7515
...
...
@@ -26,8 +26,8 @@
"-"
:
[
"Minus"
,
null
,
null
,
"NumpadSubtract"
],
"+"
:
[
"Add"
,
null
,
null
,
"NumpadAdd"
],
"Enter"
:
[
"Enter"
,
null
,
null
,
"NumpadEnter"
],
"Shift"
:
[
null
,
"ShiftLeft"
,
"ShiftRight"
,
null
],
"Control"
:
[
null
,
"ControlLeft"
,
"ControlRight"
,
null
],
"Alt"
:
[
null
,
"AltLeft"
,
"AltRight"
,
null
],
"Meta"
:
[
null
,
"MetaLeft"
,
"MetaRight"
,
null
]
"Shift"
:
[
"ShiftLeft"
,
"ShiftLeft"
,
"ShiftRight"
,
null
],
"Control"
:
[
"ControlLeft"
,
"ControlLeft"
,
"ControlRight"
,
null
],
"Alt"
:
[
"AltLeft"
,
"AltLeft"
,
"AltRight"
,
null
],
"Meta"
:
[
"MetaLeft"
,
"MetaLeft"
,
"MetaRight"
,
null
]
}
packages/flutter/lib/src/services/keyboard_maps.dart
View file @
13bf7515
...
...
@@ -2760,22 +2760,22 @@ const Map<String, List<LogicalKeyboardKey?>> kWebLocationMap = <String, List<Log
'7'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
digit7
,
null
,
null
,
LogicalKeyboardKey
.
numpad7
],
'8'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
digit8
,
null
,
null
,
LogicalKeyboardKey
.
numpad8
],
'9'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
digit9
,
null
,
null
,
LogicalKeyboardKey
.
numpad9
],
'Alt'
:
<
LogicalKeyboardKey
?>[
null
,
LogicalKeyboardKey
.
altLeft
,
LogicalKeyboardKey
.
altRight
,
null
],
'Alt'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
altLeft
,
LogicalKeyboardKey
.
altLeft
,
LogicalKeyboardKey
.
altRight
,
null
],
'ArrowDown'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
arrowDown
,
null
,
null
,
LogicalKeyboardKey
.
numpad2
],
'ArrowLeft'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
arrowLeft
,
null
,
null
,
LogicalKeyboardKey
.
numpad4
],
'ArrowRight'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
arrowRight
,
null
,
null
,
LogicalKeyboardKey
.
numpad6
],
'ArrowUp'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
arrowUp
,
null
,
null
,
LogicalKeyboardKey
.
numpad8
],
'Clear'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
clear
,
null
,
null
,
LogicalKeyboardKey
.
numpad5
],
'Control'
:
<
LogicalKeyboardKey
?>[
null
,
LogicalKeyboardKey
.
controlLeft
,
LogicalKeyboardKey
.
controlRight
,
null
],
'Control'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
controlLeft
,
LogicalKeyboardKey
.
controlLeft
,
LogicalKeyboardKey
.
controlRight
,
null
],
'Delete'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
delete
,
null
,
null
,
LogicalKeyboardKey
.
numpadDecimal
],
'End'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
end
,
null
,
null
,
LogicalKeyboardKey
.
numpad1
],
'Enter'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
enter
,
null
,
null
,
LogicalKeyboardKey
.
numpadEnter
],
'Home'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
home
,
null
,
null
,
LogicalKeyboardKey
.
numpad7
],
'Insert'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
insert
,
null
,
null
,
LogicalKeyboardKey
.
numpad0
],
'Meta'
:
<
LogicalKeyboardKey
?>[
null
,
LogicalKeyboardKey
.
metaLeft
,
LogicalKeyboardKey
.
metaRight
,
null
],
'Meta'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
metaLeft
,
LogicalKeyboardKey
.
metaLeft
,
LogicalKeyboardKey
.
metaRight
,
null
],
'PageDown'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
pageDown
,
null
,
null
,
LogicalKeyboardKey
.
numpad3
],
'PageUp'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
pageUp
,
null
,
null
,
LogicalKeyboardKey
.
numpad9
],
'Shift'
:
<
LogicalKeyboardKey
?>[
null
,
LogicalKeyboardKey
.
shiftLeft
,
LogicalKeyboardKey
.
shiftRight
,
null
],
'Shift'
:
<
LogicalKeyboardKey
?>[
LogicalKeyboardKey
.
shiftLeft
,
LogicalKeyboardKey
.
shiftLeft
,
LogicalKeyboardKey
.
shiftRight
,
null
],
};
/// Maps Windows KeyboardEvent codes to the matching [LogicalKeyboardKey].
...
...
packages/flutter/test/services/raw_keyboard_test.dart
View file @
13bf7515
...
...
@@ -2479,6 +2479,14 @@ void main() {
RawKeyEventDataWeb
.
modifierScrollLock
:
ModifierKey
.
scrollLockModifier
,
};
const
Map
<
String
,
LogicalKeyboardKey
>
modifierTestsWithNoLocation
=
<
String
,
LogicalKeyboardKey
>{
'Alt'
:
LogicalKeyboardKey
.
altLeft
,
'Shift'
:
LogicalKeyboardKey
.
shiftLeft
,
'Control'
:
LogicalKeyboardKey
.
controlLeft
,
'Meta'
:
LogicalKeyboardKey
.
metaLeft
,
};
test
(
'modifier keys are recognized individually'
,
()
{
for
(
final
int
modifier
in
modifierTests
.
keys
)
{
final
RawKeyEvent
event
=
RawKeyEvent
.
fromMessage
(<
String
,
Object
?>{
...
...
@@ -2539,6 +2547,19 @@ void main() {
}
});
test
(
'modifier keys with no location are mapped to left'
,
()
{
for
(
final
String
modifierKey
in
modifierTestsWithNoLocation
.
keys
)
{
final
RawKeyEvent
event
=
RawKeyEvent
.
fromMessage
(<
String
,
Object
?>{
'type'
:
'keydown'
,
'keymap'
:
'web'
,
'key'
:
modifierKey
,
'location'
:
0
,
});
final
RawKeyEventDataWeb
data
=
event
.
data
as
RawKeyEventDataWeb
;
expect
(
data
.
logicalKey
,
modifierTestsWithNoLocation
[
modifierKey
]);
}
});
test
(
'Lower letter keys are correctly translated'
,
()
{
final
RawKeyEvent
keyAEvent
=
RawKeyEvent
.
fromMessage
(
const
<
String
,
Object
?>{
'type'
:
'keydown'
,
...
...
packages/flutter_test/lib/src/event_simulation.dart
View file @
13bf7515
...
...
@@ -169,7 +169,7 @@ class KeyEventSimulator {
static
_WebKeyLocationPair
_getWebKeyLocation
(
LogicalKeyboardKey
key
,
String
keyLabel
)
{
String
?
result
;
for
(
final
MapEntry
<
String
,
List
<
LogicalKeyboardKey
?>>
entry
in
kWebLocationMap
.
entries
)
{
final
int
foundIndex
=
entry
.
value
.
i
ndexOf
(
key
);
final
int
foundIndex
=
entry
.
value
.
lastI
ndexOf
(
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment