Skip to content

Keyboard shortcuts fire even when PDF container is not focused #568

@mario-donnarumma

Description

@mario-donnarumma

Description

Keyboard shortcuts handled by the PDF viewer are triggered globally on the page, even when the PDF container is not focused. This causes conflicts with browser-native shortcuts and other page interactions, leading to unexpected behavior for end users.

Steps to Reproduce

  1. Navigate to any documentation page that embeds a PDF viewer, e.g. https://www.embedpdf.com/docs/snippet/theme
  2. Make sure the PDF container is not focused (e.g. click somewhere else on the page)
  3. Press CTRL+F → the PDF's internal search dialog opens instead of the browser's native page search

The issue also affects other shortcuts, for example:

  • CTRL+P → triggers the PDF's print dialog instead of the browser's native print dialog
  • CTRL+1 → triggers the "fit-to-width" action instead of switching to the first browser tab

Tested on Windows (Chrome) and MacOS (Chrome, Firefox, Safari)

Proposed Solution

  • Fix the event listeners so that shortcuts are only processed when the PDF container has focus
  • Expose a configuration option to completely or partially disable keyboard shortcuts

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions