Skip to content
React PDF Viewer

Search

Keyboard shortcuts

Navigate, zoom, rotate and go fullscreen from the keyboard while focus is in the viewer, without stealing keys from the rest of your app.

Basics

Shortcuts work while focus is anywhere inside the viewer; click the page or Tab to the document area first.

KeysAction
0Reset zoom to defaultScale.
PageUpPrevious page.
PageDownNext page.
ArrowLeftPrevious page; a zoomed page scrolls horizontally first.
ArrowRightNext page; a zoomed page scrolls horizontally first.
HomeFirst page.
EndLast page.
+Zoom in (= also works).
-Zoom out (_ also works).
rRotate clockwise.
Shift + RRotate counter-clockwise.
fToggle fullscreen.
Ctrl + FFocus the search field (⌘+F on macOS); Enter and Shift+Enter step through matches, Escape clears.

Generated from the source; see the Keyboard shortcuts reference.

Shortcuts never fire while typing in an input, select or text area, or with Alt, Ctrl or ⌘ held, so browser and app shortcuts keep working. Shift with arrows is left alone for text selection.

Toolbar and menu keys

The toolbar is a single tab stop. Inside it, ← → Home End move between controls. On the ⋮ More actions button, Enter, Space or ↓ open the menu on its first item and ↑ on its last; inside the menu, arrows move and Esc closes it and returns focus.

Turning shortcuts off

keyboardShortcuts={false} disables the viewer’s shortcuts when your app uses the same keys. Toolbar, menu and form keys keep working.

Customization

Focus indicators are CSS variables: --rpv-focus-ring and --rpv-focus-ring-offset for toolbar controls, --rpv-accent for the document area, thumbnails and links.

See the customization guide and Accessibility.

Advanced / escape hatch

To bind different keys, turn the built-in shortcuts off and call the imperative API from your own key handler:

const viewer = useRef<PdfViewerApi>(null);

useEffect(() => {
  const onKey = (event: KeyboardEvent) => {
    if (event.key === 'j') viewer.current?.nextPage();
    if (event.key === 'k') viewer.current?.previousPage();
  };
  window.addEventListener('keydown', onKey);
  return () => window.removeEventListener('keydown', onKey);
}, []);

<PdfViewer ref={viewer} source={url} keyboardShortcuts={false} />;

Limitations

  • Keys cannot be remapped. The key map is fixed. Workaround: disable it and handle keys yourself, as above.
  • Shortcuts need focus inside the viewer. They are scoped to the viewer so they never interfere with the rest of the page. Workaround: focus the viewer programmatically, or use a global handler with the imperative API.

API

  • Keyboard shortcuts — Keys the component handles, generated from @shortcut tags next to the implementation.