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();
  }
}