Skip to main content
100%

d3 zoom and pan from the keyboard

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Sep 21, 2014
Created on Sep 21, 2014

This example demonstrates keyboard-driven zooming and panning of a map rendered with D3.js, replacing typical mouse or touch interactions. A user presses arrow keys to shift the viewport, plus or minus keys to zoom in and out by a factor of two, and Escape to reset the transformation. The behavior is implemented through D3’s zoom behavior, which tracks translation and scale, and applies these values to the SVG’s transform via a transition. The code also handles legacy key codes for Safari and logs unrecognized keys to a debug console.

AI-generated description

Similar vizzes