diff --git a/lib/web_ui/lib/src/engine/keyboard.dart b/lib/web_ui/lib/src/engine/keyboard.dart index 4183cd30542..f9408d1438b 100644 --- a/lib/web_ui/lib/src/engine/keyboard.dart +++ b/lib/web_ui/lib/src/engine/keyboard.dart @@ -5,22 +5,6 @@ // @dart = 2.6 part of engine; -/// Contains a whitelist of keys that must be sent to Flutter under all -/// circumstances. -/// -/// When keys are pressed in a text field, we generally don't want to send them -/// to Flutter. This list of keys is the exception to that rule. Keys in this -/// list will be sent to Flutter even if pressed in a text field. -/// -/// A good example is the "Tab" and "Shift" keys which are used by the framework -/// to move focus between text fields. -const List _alwaysSentKeys = [ - 'Alt', - 'Control', - 'Meta', - 'Shift', - 'Tab', -]; /// Provides keyboard bindings, such as the `flutter/keyevent` channel. class Keyboard { @@ -72,10 +56,6 @@ class Keyboard { return; } - if (_shouldIgnoreEvent(event)) { - return; - } - if (_shouldPreventDefault(event)) { event.preventDefault(); } @@ -92,20 +72,6 @@ class Keyboard { _messageCodec.encodeMessage(eventData), _noopCallback); } - /// Whether the [Keyboard] class should ignore the given [html.KeyboardEvent]. - /// - /// When this method returns true, it prevents the keyboard event from being - /// sent to Flutter. - bool _shouldIgnoreEvent(html.KeyboardEvent event) { - // Keys in the [_alwaysSentKeys] list should never be ignored. - if (_alwaysSentKeys.contains(event.key)) { - return false; - } - // Other keys should be ignored if triggered on a text field. - return event.target is html.Element && - HybridTextEditing.isEditingElement(event.target); - } - bool _shouldPreventDefault(html.KeyboardEvent event) { switch (event.key) { case 'Tab': diff --git a/lib/web_ui/test/keyboard_test.dart b/lib/web_ui/test/keyboard_test.dart index 1b9e0eda0bf..c365f3c69a6 100644 --- a/lib/web_ui/test/keyboard_test.dart +++ b/lib/web_ui/test/keyboard_test.dart @@ -242,7 +242,7 @@ void main() { Keyboard.instance.dispose(); }); - test('ignores keyboard events triggered on text fields', () { + test('keyboard events should be triggered on text fields', () { Keyboard.initialize(); int count = 0; @@ -260,7 +260,7 @@ void main() { ); expect(event.defaultPrevented, isFalse); - expect(count, 0); + expect(count, 1); }); Keyboard.instance.dispose();