Skip to content

Keyboard Shortcuts

xkqg edited this page May 16, 2026 · 5 revisions

Keyboard Shortcuts

Reference table for every keyboard shortcut exposed by MatPlotLibNet's browser-side interaction scripts. Each row lists the key, the interaction it drives, the script that handles it, and the matplotlib equivalent (where one exists).

Enable the relevant script via FigureBuilder.WithZoomPan(), .WithBrowserInteraction(), .WithLegendToggle(), etc. See Home for the one-call convenience.

Treemap interaction is click-only. Since v1.7.2 Phase P the treemap script expands/collapses a parent's direct children on click (multiple parents can be expanded at once); there is no keyboard shortcut and no Escape to "pop". Leaves are not clickable.

2D charts — SvgInteractivityScript

Key Action matplotlib parity
+ / = Zoom in (10 %) NavigationToolbar2 (via toolbar, not default keymap)
- Zoom out (10 %) NavigationToolbar2
Arrow Left/Right/Up/Down Pan by ~20 data-units of viewBox — (matplotlib relies on drag)
Home Reset to original viewBox matplotlib: h, r, home all map to Home
Double-click (mouse) Reset to original viewBox matplotlib: home button
Hold x then drag Pan locked to X axis matplotlib _base.py:format_deltas — same key
Hold y then drag Pan locked to Y axis matplotlib _base.py:format_deltas — same key

Wheel, pinch, pan and reset are all detailed in Interactive Controls.

3D charts — Svg3DRotationScript

Key Action matplotlib parity
Arrow Left/Right Rotate azimuth by ∓5° matplotlib axes3d — same direction
Arrow Up/Down Rotate elevation by ±5° matplotlib axes3d — same direction
+ Decrease camera distance by 0.5 (zoom in) — (matplotlib 3D has no default keymap)
- Increase camera distance by 0.5 (zoom out)
Home Reset elevation / azimuth / distance to initial matplotlib axes3d home
Drag (pointer) Rotate camera; full-axes drag = 180° matplotlib axes3d _on_move (Phase B.2)
Wheel Change camera distance (always works — Phase F.3) — (matplotlib 3D)

Legend items — SvgLegendToggleScript + SvgLegendDragScript

Key / pointer Action WCAG / version
Enter Toggle series visibility (same as click) 2.1.1 Level A
Space Toggle series visibility (same as click) 2.1.1 Level A
Click (no drag) Toggle series visibility v0.8.8 — fired on pointerdown until v1.7.2 Phase S, now fires on click only so press-and-hold doesn't toggle prematurely
Press-and-hold a legend item, drag, release Reposition the entire <g class="legend"> group (translation is client-only — lost on full server re-render) v1.7.2 Phase S

Each legend badge also carries role="button", tabindex="0", and toggles aria-pressed so assistive tech announces state changes. The drag listener uses capture-phase stopPropagation to keep pan/zoom from racing for setPointerCapture, and a one-shot capture-phase click swallower after a real drag (>5 px²) suppresses the synthetic click that would otherwise fire toggle on drop.

Rich tooltips — SvgCustomTooltipScript

Key Action
Tab (focus) Move to next tooltip target; tip appears at element bounds
Shift+Tab (focus) Move to previous tooltip target
Blur (Tab away) Hides tooltip

Focus positioning honours getBoundingClientRect() (Phase 12 of v1.7.2 plan) — keyboard focus no longer jumps the tip to (0, 0).

Selection (Shift-drag brush) — SvgSelectionScript

Key Action
Shift + pointerdownpointermovepointerup Create selection rectangle, emit mpl:selection CustomEvent with {x1, y1, x2, y2} payload
Escape (during drag) Cancel selection — rectangle removed, no event dispatched

Sankey hover — SvgSankeyHoverScript

Key Action
Tab → focus a node Emphasise upstream + downstream reachable links (keyboard parity with mouse hover)
Shift+Tab → blur Restore all links to their base opacity

Every node rect receives tabindex="0" so the focus chain walks the graph.

SignalR server-routed (WithServerInteraction(...)) — SvgSignalRInteractionScript

All of the 2D shortcuts above are intercepted and forwarded to the SignalR hub as OnZoom / OnPan / OnReset / OnLegendToggle / OnBrushSelect / OnHover invocations. The hub mutates the server-side figure and pushes the updated SVG back to all connected clients. See Bidirectional SignalR.

Accessibility notes

  • Every interactive element receives role="button", tabindex="0", and an aria-label appropriate to its context. Enter / Space activate as expected per WCAG 2.1.1 Level A.
  • The 3D <g class="mpl-3d-scene"> also carries tabindex="0" so keyboard users can rotate it with arrows + reset with Home after tabbing to it.
  • The tooltip <div> has role="tooltip" and aria-live="polite" so screen readers announce content on hover and focus.
  • See also Accessibility for the broader a11y contract.

Clone this wiki locally