tomoki1207 / vscode-pdfviewer

Show PDF preview in VSCode.
https://marketplace.visualstudio.com/items/tomoki1207.pdf
Other
296 stars 70 forks source link

Suggestion to add keyboard shortcut, similar to mupdf #20

Open ipstone opened 6 years ago

ipstone commented 6 years ago

Hello,

I would like to propose a future feature of keyboard shortcut, such as those in mupdf? We can have some simple keybindings (such as j, k, . and , navigation keys) first. Not sure if these are already configurable or not. Thanks

Here are the info from mupdf man page: KEY BINDINGS Page navigation:

   . pgdn right space
          Go to the next page.

   , pgup left b backspace
          Go to the previous page.

   <, >   Skip back/forth 10 pages at a time.

   123g   Go to page 123.

   g, G   Go to the first or last page.

   m      Mark current page for snap back. Up to 256 pages can be marked.

   t      Pop back to the latest mark.

   [0-9]m Save the current page number in the numbered register.

   [0-9]t Go to the page saved in the numbered register.

   Zooming and rotating:

   +, -   Zoom in or out.

   W, H   Zoom page to exactly fit width/height of window.

   Z      Zoom page to fit either to width or height of window.

   L, R   Rotate page left (counter-clockwise) or right (clockwise).

   w      Shrinkwrap window to fit the page.

   f      Toggles fullscreen mode.

   Panning:

   h, j, k, l
          Pan page left, down, up, or right.

   Searching:

   /, ?   Search for text forwards or backwards.

   n, N   Find the next/previous search result.
codery2k commented 3 years ago

I can confirm that the shortcuts supported by pdf.js are working. A list of these can be found in the pdf.js FAQs, here. One problem you might face, which I did, is that some shortcuts are common to vscode's workbench shortcuts. For instance, the default zoom-in shortcut, Ctrl +, is by default assigned to workbench.action.zoomIn. This overrides the pdf zoom function, resulting in the whole workbench being zoomed in instead of just the pdf. I get around this by assigning a different shortcut to the workbench action, like Ctrl Alt +. This frees up the pdf.js shortcut and it works nicely on just the pdf.

@tomoki1207, I think a premanent solution to this would involve defining default keyboard shortcuts for this extension that are displayed under File>Preferences>Keyboard Shortcuts. Also setting their priority higher than those for workbench actions, if priority setting is possible. This is just thinking how it could be implemented, I'm not really sure of the low level code. I haven't worked on a vscode extension, though I'm open to try my hand at it if the approach seems fine to you :)