Adding support for logical and physical key events (#27627)

This adds support for logical and physical key information inside of RawKeyEvent. This allows developers to differentiate keys in a platform-agnostic way. They are able to tell the physical location of a key (PhysicalKeyboardKey) and a logical meaning of the key (LogicalKeyboardKey), as well as get notified of the character generated by the keypress. All of which is useful for handling keyboard shortcuts.

This PR builds on the previous PR (#27620) which generated the key code mappings and definitions.
This commit is contained in:
Greg Spencer
2019-02-08 12:42:34 -08:00
committed by GitHub
parent b7807ce84c
commit 431cfdafd9
15 changed files with 4771 additions and 85 deletions

View File

@@ -89,6 +89,8 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
dataText.add(Text('hidUsage: ${data.hidUsage} (${_asHex(data.hidUsage)})'));
dataText.add(Text('modifiers: ${data.modifiers} (${_asHex(data.modifiers)})'));
}
dataText.add(Text('logical: ${_event.logicalKey}'));
dataText.add(Text('physical: ${_event.physicalKey}'));
for (ModifierKey modifier in data.modifiersPressed.keys) {
for (KeyboardSide side in KeyboardSide.values) {
if (data.isModifierPressed(modifier, side: side)) {