allefeld / atom-pdfjs-viewer

Themed, fully featured PDF viewer for the Atom editor
MIT License
12 stars 3 forks source link

pdf.js's keyboard shortcuts supercede Atom's (Mac) #13

Closed corybrunson closed 3 years ago

corybrunson commented 3 years ago

This package overrides Atom's keyboard shortcuts, perhaps most notably the ability to cycle through Atom tabs, but only when the viewer is engaged in the current tab. So, on my Mac, for example, i can command + alt + right from a Markdown tab to its PDF tab, but i can't command + alt + left back to the Markdown tab.

I don't know if this is because Atom's shortcuts are made inaccessible or because conflicts arise and pdf.js's shortcuts take precedence. Though the tab navigation shortcuts above don't seem to do anything in pdf.js.

I understand the usefulness of the pdf.js keyboard shortcuts. Could an option be added that disables pdf.js's keyboard shortcuts? (I at least would use them during some phases of work but only Atom's during others.)

That said, this is an excellent substitute for the recently-broken pdf-view(-plus) packages, for which thanks!

allefeld commented 3 years ago

Glad you like the viewer. How is pdf-view(-plus) broken?

I'm afraid this can't be changed without substantially modifying the underlying PDF.js viewer. The viewer runs in an iframe, with its own event processing. The rest of Atom, including my package, doesn't even notice when keyboard events occur within the scope of the viewer. I'm guessing it might be possible to hack the viewer, intercept keyboard events, and somehow conditionally transfer them out of the iframe and into Atom's event queue, but that's beyond my JS skills. If anyone knows how to do this, contributions welcome.

corybrunson commented 3 years ago

@allefeld thank you for the explanation! I may eventually move to a different viewer, but i'm very glad to have found pdfjs when i needed it. : )