handleKeyboardCommand method

bool handleKeyboardCommand(
  1. String key, {
  2. bool control = false,
  3. bool meta = false,
  4. bool shift = false,
})

Handles a keyboard command for the selected canvas object.

Implementation

bool handleKeyboardCommand(
  String key, {
  bool control = false,
  bool meta = false,
  bool shift = false,
}) {
  final shortcut = control || meta;
  final normalized = key.toLowerCase();
  if (shortcut && normalized == 'c') return copySelected();
  if (shortcut && normalized == 'v') return pasteCopied().isNotEmpty;
  if (key == 'Delete' || key == 'Backspace') return deleteSelected();
  if (key == 'ArrowLeft') return nudgeSelected(dx: -1, largeStep: shift);
  if (key == 'ArrowRight') return nudgeSelected(dx: 1, largeStep: shift);
  if (key == 'ArrowUp') return nudgeSelected(dy: -1, largeStep: shift);
  if (key == 'ArrowDown') return nudgeSelected(dy: 1, largeStep: shift);
  return false;
}