Skip to content

Keyboard Shortcuts

H.P. Gansevoort edited this page Sep 12, 2026 · 7 revisions

Keyboard Shortcuts

This page lists every keyboard shortcut in MatPlotLibNet's browser-side interaction scripts. For each shortcut it gives the key, what the key does, which script handles it, and the matplotlib equivalent where one exists. Enable the relevant script with FigureBuilder.WithZoomPan(), .WithBrowserInteraction(), .WithLegendToggle(), and so on. See Home for the one-call convenience.

Treemap interaction is click-only. Since v1.7.2 Phase P, the treemap script expands or collapses a parent's direct children when you click the parent. More than one parent can be expanded at once. There is no keyboard shortcut, and pressing Escape does not collapse the parent again. 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 the camera; a drag across the full axes rotates 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 a press-and-hold does not toggle too early
Press-and-hold a legend item, drag, release Reposition the entire <g class="legend"> group (the translation is client-only and is lost on a full server re-render) v1.7.2 Phase S

Each legend badge carries role="button" and tabindex="0", and toggles aria-pressed so that assistive technology announces the state change. The drag listener calls stopPropagation in the capture phase so that the pan/zoom handlers cannot race setPointerCapture. After a real drag (more than 5 px²), a one-shot handler discards the synthetic toggle click that the browser fires when you release the pointer.

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 uses getBoundingClientRect() (Phase 12 of the v1.7.2 plan), so keyboard focus no longer jumps the tip to (0, 0).

Selection (Shift-drag brush) — SvgSelectionScript

Key Action
Shift + pointerdown→pointermove→pointerup Create a selection rectangle and emit an mpl:selection CustomEvent with a {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 the reachable upstream and downstream links (the same as mouse hover)
Shift+Tab → blur Restore all links to their base opacity

Every node rect receives tabindex="0", so pressing Tab moves focus from node to node through the graph.

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

The script intercepts all of the 2D shortcuts above and forwards them to the SignalR hub as OnZoom / OnPan / OnReset / OnLegendToggle / OnBrushSelect / OnHover invocations. The hub updates 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 that fits its context. Enter and Space activate the element, as WCAG 2.1.1 Level A expects.
  • The 3D <g class="mpl-3d-scene"> also carries tabindex="0". After tabbing to it, keyboard users can rotate it with the arrow keys and reset it with Home.
  • The tooltip <div> has role="tooltip" and aria-live="polite", so screen readers announce its content on hover and on focus.
  • See also Accessibility for the wider accessibility contract.

Clone this wiki locally