Skip to content

Keyboard Shortcuts

VitePress Mermaid provides intuitive keyboard shortcuts for efficient diagram navigation.

Available Shortcuts

ShortcutActionDescription
ESCClose PreviewCloses the fullscreen preview modal
Ctrl/Cmd + +Zoom InIncreases the zoom level
Ctrl/Cmd + -Zoom OutDecreases the zoom level
Ctrl/Cmd + 0Reset ZoomResets to the original zoom level

Mouse Interactions

ActionFunction
Click diagramOpens fullscreen preview
Scroll wheelZoom in/out at cursor position
DragPan around when zoomed in
Click X buttonClose preview
Click backdropClose preview

Touch Gestures (Mobile)

GestureFunction
Tap diagramOpens fullscreen preview
PinchZoom in/out
SwipePan around when zoomed in
Tap X buttonClose preview

Usage Examples

Quick Navigation

  1. Click on a diagram to open it
  2. Use Ctrl + + several times to zoom in
  3. Drag to pan to the area of interest
  4. Press ESC to close when done

Detailed Examination

Loading diagram...

Try the shortcuts on the diagram above!

Zoom Levels

The preview supports a wide range of zoom levels:

  • Minimum: 0.1x (10% of original size)
  • Maximum: 10x (1000% of original size)
  • Step: 0.1x increments

Accessibility

All keyboard shortcuts are designed to be:

  • Discoverable - Shown in the UI
  • Consistent - Match common patterns (e.g., browser zoom)
  • Non-intrusive - Don't interfere with page navigation

Focus Management

When the preview opens:

  • Focus moves to the modal container
  • Tab navigation is trapped within the modal
  • Pressing ESC returns focus to the trigger element

Customization

Currently, keyboard shortcuts are fixed for consistency. Future versions may allow customization through configuration.

Tips

  1. Zoom before panning - Zoom in first, then drag to explore
  2. Use keyboard for precision - Keyboard shortcuts offer finer control than scroll
  3. Reset when lost - Ctrl/Cmd + 0 quickly returns to the full view
  4. ESC is your friend - The fastest way to close and continue reading

Released under the MIT License.