onKey method

  1. @protected
bool onKey(
  1. KeyEvent event
)

Used to check if ctrl or shift for scrolling is pressed

Implementation

@protected
bool onKey(KeyEvent event) {
  final key = event.logicalKey;

  if (key == LogicalKeyboardKey.controlLeft ||
      key == LogicalKeyboardKey.controlRight) {
    if (event is KeyDownEvent || event is KeyRepeatEvent) {
      _ctrlPressed = true;
    } else if (event is KeyUpEvent) {
      _ctrlPressed = false;
    }
  }

  if (key == LogicalKeyboardKey.shiftLeft ||
      key == LogicalKeyboardKey.shiftRight) {
    if (event is KeyDownEvent || event is KeyRepeatEvent) {
      _shiftPressed = true;
    } else if (event is KeyUpEvent) {
      _shiftPressed = false;
    }
  }

  return false;
}