typeSpecialKey method

void typeSpecialKey(
  1. PageLoaderSpecialKey key, {
  2. bool keyDown = true,
  3. bool keyUp = true,
})

Adds to sequence: ('keydown', 'keyup') events on key. If the special key is enter, also adds 'keypress'.

keyDown and keyUp determines whether those events should be sent.

Implementation

void typeSpecialKey(PageLoaderSpecialKey key,
    {bool keyDown = true, bool keyUp = true}) {
  final keyString = _specialKeyToKeyProperty[key]!;
  if (keyDown) {
    switch (key) {
      case PageLoaderSpecialKey.alt:
        _altMod = true;
        break;
      case PageLoaderSpecialKey.control:
        _ctrlMod = true;
        break;
      case PageLoaderSpecialKey.meta:
        _metaMod = true;
        break;
      case PageLoaderSpecialKey.shift:
        _shiftMod = true;
        break;
      default:
        break;
    }
    _addEvent(key, keyString, KeyboardEventType.keyDown);

    // 'enter' still sends a keypress.
    if (key == PageLoaderSpecialKey.enter) {
      _addEvent(key, keyString, KeyboardEventType.keyPress);
    }
  }
  if (keyUp) {
    switch (key) {
      case PageLoaderSpecialKey.alt:
        _altMod = false;
        break;
      case PageLoaderSpecialKey.control:
        _ctrlMod = false;
        break;
      case PageLoaderSpecialKey.meta:
        _metaMod = false;
        break;
      case PageLoaderSpecialKey.shift:
        _shiftMod = false;
        break;
      default:
        break;
    }
    _addEvent(key, keyString, KeyboardEventType.keyUp);
  }
  _addUniqueEvent(key, keyString);
}