3
3
This directory contains a keycode generator that can generate Dart code for
4
4
the ` LogicalKeyboardKey ` and ` PhysicalKeyboardKey ` classes.
5
5
6
- It generates multiple files across Flutter. For framework, it generates
6
+ It generates multiple files across Flutter. For framework, it generates
7
7
8
8
* [ ` keyboard_key.dart ` ] ( ../../../packages/flutter/lib/src/services/keyboard_key.dart ) , which contains the definition and list of logical keys and physical keys; and
9
9
* [ ` keyboard_maps.dart ` ] ( ../../../packages/flutter/lib/src/services/keyboard_maps.dart ) , which contains platform-specific immutable maps used for the ` RawKeyboard ` API.
10
10
11
- For engine, it generates one key mapping file for each platform.
11
+ For engine, it generates one key mapping file for each platform, as well as some
12
+ files for testing purposes.
12
13
13
14
It draws information from various source bases, including online
14
- repositories, and manual mapping in the ` data ` subdirectory. It incorporates
15
+ repositories, and manual mapping in the ` data ` subdirectory. It incorporates
15
16
this information into a giant list of physical keys
16
17
([ ` physical_key_data.json ` ] ( data/physical_key_data.json ) ),
17
18
and another for logical keys
@@ -38,46 +39,45 @@ This will generate `physical_key_data.json` and `logical_key_data.json`. These
38
39
files should be checked in.
39
40
40
41
By default this tool assumes that the gclient directory for flutter/engine
41
- and the root for the flutter/flutter are placed at the same folder. If not,
42
+ and the root for the flutter/flutter are placed at the same folder. If not,
42
43
use ` --engine-root=/ENGINE/GCLIENT/ROOT ` to specify the engine root.
43
44
44
45
Other options can be found using ` --help ` .
45
46
46
- ## Logical Key ID Scheme
47
+ ## Key ID Scheme
47
48
48
- To provide logical keys with unique ID codes, Flutter uses a scheme
49
- to assign logical keycodes which keeps us out of the business of minting new
50
- codes ourselves. This only applies to logical key codes: Flutter's
51
- physical key codes are just defined as USB HID codes.
49
+ To provide keys with unique ID codes, Flutter uses a scheme to assign keycodes
50
+ which keeps us out of the business of minting new codes ourselves. This applies
51
+ both logical keys and physical keys.
52
52
53
- The logical codes are meant to be opaque to the user, and should never be
54
- unpacked for meaning, since the coding scheme could change at any time and the
55
- meaning is likely to be retrievable more reliably and correctly from
56
- the API.
53
+ The codes are meant to be opaque to the user, and should never be unpacked for
54
+ meaning, since the coding scheme could change at any time and the meaning is
55
+ likely to be retrievable more reliably and correctly from the API.
57
56
58
57
However, if you are porting Flutter to a new platform, you should follow the
59
- following guidelines for specifying logical key codes.
58
+ following guidelines for specifying key codes.
60
59
61
- The logical key code is a 52-bit integer (due to the limitation of JavaScript).
62
- The entire namespace is divided into 32-bit * planes* . The upper 20 bits of the
63
- ID represent the plane ID, while the lower 32 bits represent values in the
64
- plane. For example, plane 0x1 refers to the range 0x1 0000 0000 -
65
- 0x1 FFFF FFFF. Each plane manages how the values within the range are assigned.
60
+ The key code is a 52-bit integer (due to the limitation of JavaScript). The
61
+ entire namespace is divided into 32-bit * planes* . The upper 20 bits of the ID
62
+ represent the plane ID, while the lower 32 bits represent values in the plane.
63
+ For example, plane 0x1 refers to the range 0x1 0000 0000 - 0x1 FFFF FFFF. Each
64
+ plane manages how the values within the range are assigned.
66
65
67
66
The planes are planned as follows:
68
67
69
- - ** Plane 0x00** : The Unicode plane. This plane contains keys that generate Unicode
70
- characters when pressed (this includes dead keys, but not e.g. function keys
71
- or shift keys). The value is defined as the Unicode code point corresponding
72
- to the character, lower case and without modifier keys if possible.
73
- Examples are Key A (0x61), Digit 1 (0x31), Colon (0x3A), and Key Ù (0xD9).
74
- (The "Colon" key represents a keyboard key that prints the ":"
75
- character without modifiers, which can be found on the French layout. On the
76
- US layout, the key that prints ":" is the Semicolon key.)
77
- This plane also contains key None (0x0).
78
-
79
- - ** Plane 0x01** : The unprintable plane. This plane contains keys that are defined
80
- by the [ Chromium key list] ( https://chromium.googlesource.com/codesearch/chromium/src/+/refs/heads/master/ui/events/keycodes/dom/dom_key_data.inc )
68
+ - ** Plane 0x00** : The Unicode plane. For logical keys, this plane contains keys
69
+ that generate Unicode characters when pressed (this includes dead keys, but
70
+ not e.g. function keys or shift keys). The value is defined as the Unicode
71
+ code point corresponding to the character, lower case and without modifier
72
+ keys if possible. Examples are Key A (0x61), Digit 1 (0x31), Colon (0x3A),
73
+ and Key Ù (0xD9). (The "Colon" key represents a keyboard key that prints the
74
+ ":" character without modifiers, which can be found on the French layout. On
75
+ the US layout, the key that prints ":" is the Semicolon key.) For physical
76
+ keys, this plane contains keys from USB HID usages.
77
+
78
+ - ** Plane 0x01** : The unprintable plane. This plane contains logical keys that
79
+ are defined by the [ Chromium key
80
+ list] ( https://chromium.googlesource.com/codesearch/chromium/src/+/refs/heads/master/ui/events/keycodes/dom/dom_key_data.inc )
81
81
and do not generate Unicode characters. The value is defined as the macro
82
82
value defined by the Chromium key list. Examples are CapsLock (0x105),
83
83
ArrowUp (0x304), F1 (0x801), Hiragata (0x716), and TVPower (0xD4B).
@@ -86,11 +86,10 @@ The planes are planned as follows:
86
86
information.
87
87
88
88
- ** Plane 0x02** : The Flutter plane. This plane contains keys that are
89
- defined by Flutter. The values are also manually assigned by Flutter.
90
- Modifier keys are placed in this plane, because Flutter distinguishes
91
- between sided modifier keys (for example "ShiftLeft" and "ShiftRight"),
92
- while the web doesn't (only has "Shift").
93
- Other examples are numpad keys and gamepad keys.
89
+ defined by Flutter. Modifier keys are placed in this plane, because Flutter
90
+ distinguishes between sided modifier keys (for example "ShiftLeft" and
91
+ "ShiftRight"), while the web doesn't (only has "Shift"). Other examples are
92
+ numpad keys and gamepad keys.
94
93
95
94
- ** Plane 0x03-0x0F** : Reserved.
96
95
@@ -114,8 +113,7 @@ The planes are planned as follows:
114
113
recognized by Flutter.
115
114
116
115
The value scheme within a platform plane is decided by the platform,
117
- typically using the field from the platform's native key event that
118
- represents the key's logical effect (such as ` keycode ` , ` virtual key ` , etc).
116
+ typically using the other fields from the platform's native key event.
119
117
120
118
In time, keys that originally belong to a platform plane might be added to
121
119
Flutter, especially if a key is found shared by multiple platforms. The values
@@ -129,5 +127,5 @@ The planes are planned as follows:
129
127
to use the platform-plane value to avoid adding platform-exclusive values
130
128
to the framework.
131
129
132
- - ** Plane 0x20-0x2F** : Custom platform planes. Similar to Flutter's platform
130
+ - ** Plane 0x20-0x2F** : Custom platform planes. Similar to Flutter's platform
133
131
planes, but for private use by custom platforms.
0 commit comments