# Keyboard shortcuts

A viewer's shortcuts act only for that viewer: when the key comes from inside it, or when focus is on the page itself and the viewer was the last thing the user clicked or focused. A viewer takes the page-level keys (PageDown, Home, Ctrl/Cmd+P, Ctrl/Cmd+F, Ctrl/Cmd+Z, the zoom keys) only once the user has clicked or focused inside it — until then, and again once the user clicks elsewhere on your page, those keys are your page's own. Two viewers on one page never both act.

The page and zoom keys, Print, Undo/Redo, Find and the sidebar key are ignored while a text field, list or editable element has focus, and are off with [`navigation.keyboardShortcuts: false`](https://kernstra.com/docs/web-sdk/config/navigation/keyboardshortcuts). Escape always leaves the current tool, so a viewer can never trap the user in one: it stays on with `keyboardShortcuts: false`, and inside one of the viewer's own text fields the field handles it first. The keys that act on something you have selected (the Selections and Search Bar tables, `Delete` on a placed object, and `Enter` in Add Text) belong to that control and stay on. A key that the toolbar or a selected object is using (an arrow, `Home`, `End`) does not also turn the page.

## Example

```ts
new PDFViewer(container, doc, {
  navigation: { keyboardShortcuts: true },
});
```

## Navigation & Zoom

| Shortcut | Action |
| --- | --- |
| `ArrowLeft` / `PageUp` | Previous page |
| `ArrowRight` / `PageDown` | Next page |
| `Home` | First page |
| `End` | Last page |
| `Ctrl/Cmd + =` | Zoom in |
| `Ctrl/Cmd + -` | Zoom out |
| `Ctrl/Cmd + 0` | Fit page |
| `Ctrl/Cmd + 1` | Fit width |
| `Ctrl/Cmd + P` | Print, exactly as the toolbar's Print button: your `callbacks.onPrint` if set, otherwise the SDK's print, asking first unless `print.ask: false`. With `toolbar.print: false`, or a license without printing, the browser gets the key |

## Editing

| Shortcut | Action |
| --- | --- |
| `Ctrl/Cmd + Z` | Undo (also with the buttons hidden by `toolbar.history: false`) |
| `Ctrl/Cmd + Y` or `Ctrl/Cmd + Shift + Z` | Redo |
| `Ctrl/Cmd + F` | Open or close the search bar; with Search off (`tools.search: false`) the browser's own find gets the key |
| `Escape` | Leave the open block (first press) / leave the tool (second press). In Edit Text the second press writes the edits, as Done does |
| `Enter` | Confirm text input (Add Text) |
| `Delete` / `Backspace` | Delete the selected placed object (stamp, image, shape, added text, signature) or the selected annotation the document came with |
| `Ctrl/Cmd + \` | Open or close the sidebar |

## Selections

| Shortcut | Action |
| --- | --- |
| `Tab` / `Shift + Tab` | Edit Text: the next / previous text block |
| `Enter` | Edit Text: edit the selected block. A placed object: put it down |
| Arrow keys | A placed object: move it 1 screen pixel (`Shift`: 10) |
| `Escape` | A placed object: cancel the move or resize |
| `Delete` / `Backspace` | Manage Pages: delete the selected pages |

## Comments panel

| Shortcut | Action |
| --- | --- |
| `Tab` / `Shift + Tab` | The next / previous comment card |
| `Enter` / `Space` on a card | Choose it: its mark is scrolled to and outlined |
| `Ctrl/Cmd + Enter` | Send the reply or the edit being written |
| `Escape` in a reply or an edit | Cancel it |
| `ArrowDown` / `ArrowUp` in a menu | Move through a card's menu; `Escape` closes it |

## Search Bar

| Shortcut | Action |
| --- | --- |
| `Enter` | Find next match |
| `Shift + Enter` | Find previous match |
| `Escape` | Close search bar |

## Notes

**Keyboard access.** **Skip link:** the first Tab stop in the viewer is "Skip to the document", visible only while it has focus; it puts focus on the page area.

**The toolbar is one Tab stop.** Tab reaches it, `ArrowLeft` / `ArrowRight` move between its controls, `Home` / `End` jump to the ends, and Tab leaves it. The active tool's button is the one Tab lands on. The ribbon's tab strip moves between tabs with `ArrowLeft` / `ArrowRight`.

**Dialogs trap focus** — the download, print, link, signature and security dialogs keep Tab inside while open and return focus to whatever opened them when they close.

**What a screen reader hears.** A polite live region announces tool changes ("Highlight tool active", "Highlight tool closed"), page changes ("Page 4 of 6"), the sidebar opening and closing, and completions such as a finished download. Errors are announced assertively.

**Focus ring.** One ring everywhere: 2 px of the accent, 2 px outside the control, drawn only for keyboard focus (`:focus-visible`), and the system highlight color under forced-colors mode. See [Theme tokens](https://kernstra.com/docs/web-sdk/guides/theme-tokens) for `--ks-focus-ring` and `--ks-focus-offset`.


Web page: https://kernstra.com/docs/web-sdk/guides/keyboard
