Keyboard shortcuts
Default key map, wired automatically by <DocViewer>. Mod = Ctrl
on Windows / Linux, Cmd on macOS.
Global
| Shortcut | Action |
|---|---|
Mod+F | Open search (works even while typing in an input) |
Mod+P | Open print dialog |
Mod+S | Open save dialog |
Mod+Z | Undo annotation change |
Mod+Shift+Z / Mod+Y | Redo annotation change |
Escape | Cancel active tool (back to text selection), dismiss panels / modals |
Navigation
No modifier needed:
| Shortcut | Action |
|---|---|
↓ / Page Down | Next page |
↑ / Page Up | Previous page |
Home | First page |
End | Last page |
+ / = | Zoom in |
- / _ | Zoom out |
0 | Reset to 100% |
Annotation editing
| Shortcut | Action |
|---|---|
Mod+C | Copy selected annotations |
Mod+X | Cut selected annotations |
Mod+V | Paste onto the current page |
Mod+D | Duplicate the selection in place |
Mod+A | Select every annotation on the current page |
Delete / Backspace | Delete the selection (one undo step) |
Tools
Single letter, no modifier:
| Key | Tool |
|---|---|
V | Select |
E | Eraser |
H | Highlight |
U | Underline |
K | Strikethrough |
Q | Squiggly |
I | Freehand ink |
T | Free text |
S | Sticky note |
R | Rectangle |
O | Ellipse |
L | Line |
A | Arrow |
M | Rubber stamp |
D | Distance |
C | Count |
X | Mark for redaction |
Text inputs and on-screen keyboards
Every shortcut except Mod+F and Escape is suppressed while an
<input>, <textarea>, <select>, or contenteditable element has
focus — users can type freely into form fields and free-text
annotations, and on-screen keyboards never trigger tool switches
accidentally.
Custom chrome
Hosts that render their own UI around the engine (instead of the
full <DocViewer>) can reuse the same key map:
import { useKeyboardShortcuts } from '@trupdf/viewer';
useKeyboardShortcuts(engine, {
onSearchOpen: () => searchInput.current?.focus(),
onPrintOpen: () => setPrintDialogOpen(true),
onSaveOpen: () => setSaveDialogOpen(true),
onEscape: () => closePanels(),
target: viewerRootEl, // defaults to window; pass an element to scope
});All callbacks are optional — omit onPrintOpen and Mod+P does
nothing, which is also the simplest way to opt out of a shortcut in
a custom-chrome build. Pass target to keep the listeners scoped to
the viewer element so the rest of your app keeps its own shortcut
handling.
Plugin hotkey hints
The hotkey field on a plugin ToolbarAction (or preset button) is
a display hint — it renders in the button's tooltip so users can
discover it. Bind the actual key handling in your host:
sdk.install({
id: 'review-plugin',
toolbar: [{
id: 'mark-reviewed',
label: 'Mark reviewed',
hotkey: 'Mod+R', // shown in the tooltip
handler: () => markReviewed(),
}],
});