handleKeyDown method

dynamic handleKeyDown(
  1. dynamic event
)

Implementation

handleKeyDown(event) {
  var needsUpdate = false;

  switch (event.code) {
    case Keys.up:
      pan(0, scope.keyPanSpeed);
      needsUpdate = true;
      break;

    case Keys.bottom:
      pan(0, -scope.keyPanSpeed);
      needsUpdate = true;
      break;

    case Keys.left:
      pan(scope.keyPanSpeed, 0);
      needsUpdate = true;
      break;

    case Keys.right:
      pan(-scope.keyPanSpeed, 0);
      needsUpdate = true;
      break;
  }

  if (needsUpdate) {
    // prevent the browser from scrolling on cursor keys
    event.preventDefault();

    scope.update();
  }
}