[Jisho Userscript] Jisho Basic Keyboard Navigation

When I read Japanese books I use jisho.org a lot. I mostly read on my computer, so I mostly keep my hands on the keyboard. Sometimes when jisho can’t recognize a search query, the input field loses focus and I have to take the mouse and click again on the input field which I then have to clear with Backspace. Another situation is when I get to the end of the long list of search results and have to scroll all the way back to top. It’s not a big deal, but after some number of repetitions it gets annoying.
That’s why I created a simple script that allows a simple keyboard-only navigation with key combinations:

  • Alt + Q : scroll back to top and focus input field
  • Alt + K : scroll up
  • Alt + J : scroll down
  • Alt + N : click “More Words” link

If you want to use other keys, you can edit the code of the script. Here are the values to check for:

  • e.altKey Alt
  • e.ctrlKey Ctrl
  • e.shiftKey Shift
  • for letter keys you need to use comparison: e.code === "KeyX"
  • just look at the existing code to get the idea :smile:

If you want to change the speed of scroll, change the value of top in the line window.scrollBy({ top: 200, left: 0, behavior: "smooth" }); (and the other one for scrolling up).

7 Likes

Cool idea. This has bugged me for a while. Aren’t J and K usually the opposite though? For example, here on the forums J selects the next post (down) while K selects the previous post (up).

4 Likes

Interesting, I didn’t know that. I’ll change it for consistency then.

4 Likes

That also maps perfectly to vi commands for up (k) and down (j) so my muscle memory thanks you :slight_smile:

4 Likes