handleKeyExtended method

bool handleKeyExtended(
  1. KeyEvent event, {
  2. bool ctrl = false,
})

Handles a key event with extended controls (word movement, etc.).

Ctrl+Left/Right for word movement, Ctrl+Backspace for word delete. Returns true if the input was modified.

Implementation

bool handleKeyExtended(KeyEvent event, {bool ctrl = false}) {
  if (!ctrl) return handleKey(event);

  switch (event.type) {
    case KeyEventType.arrowLeft:
      final oldPos = _cursorPosition;
      moveCursorWordLeft();
      return _cursorPosition != oldPos;

    case KeyEventType.arrowRight:
      final oldPos = _cursorPosition;
      moveCursorWordRight();
      return _cursorPosition != oldPos;

    case KeyEventType.backspace:
      return backspaceWord();

    default:
      return handleKey(event);
  }
}