sendKeyDownEvent method Null safety
- LogicalKeyboardKey key,
- {String? character,
- String platform = _defaultPlatform}
Simulates sending a physical key down event.
This only simulates key down events coming from a physical keyboard, not from a soft keyboard.
Specify platform
as one of the platforms allowed in
platform.Platform.operatingSystem to make the event appear to be from
that type of system. Defaults to "web" on web, and "android" everywhere
else. Must not be null. Some platforms (e.g. Windows, iOS) are not yet
supported.
Whether the event is sent through RawKeyEvent or KeyEvent is controlled by debugKeyEventSimulatorTransitModeOverride.
Keys that are down when the test completes are cleared after each test.
Returns true if the key event was handled by the framework.
See also:
- sendKeyUpEvent and sendKeyRepeatEvent to simulate the corresponding key up and repeat event.
- sendKeyEvent to simulate both the key up and key down in the same call.
Implementation
Future<bool> sendKeyDownEvent(LogicalKeyboardKey key, { String? character, String platform = _defaultPlatform }) async {
assert(platform != null);
// Internally wrapped in async guard.
return simulateKeyDownEvent(key, character: character, platform: platform);
}