onKey method

  1. @override
bool onKey(
  1. KeyEvent event,
  2. RenderContext ctx
)
override

Implementation

@override
bool onKey(KeyEvent event, RenderContext ctx) {
  switch (event.key) {
    case NamedKey.arrowLeft:
      _shiftDays(-1);
      return true;
    case NamedKey.arrowRight:
      _shiftDays(1);
      return true;
    case NamedKey.arrowUp:
      _shiftDays(-7);
      return true;
    case NamedKey.arrowDown:
      _shiftDays(7);
      return true;
    case NamedKey.pageUp:
      _shiftMonths(-1);
      return true;
    case NamedKey.pageDown:
      _shiftMonths(1);
      return true;
    case NamedKey.home:
      _moveCursor(DateTime(state.cursor.year, state.cursor.month, 1));
      return true;
    case NamedKey.end:
      final lastDay =
          DateTime(state.cursor.year, state.cursor.month + 1, 0).day;
      _moveCursor(DateTime(state.cursor.year, state.cursor.month, lastDay));
      return true;
    case NamedKey.enter:
      _select();
      return true;
    default:
      if (event.char == '[') {
        _shiftYears(-1);
        return true;
      }
      if (event.char == ']') {
        _shiftYears(1);
        return true;
      }
      return false;
  }
}