FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.06k stars 213 forks source link

Idea for Yomichan - Scroll through text with Arrow Keys #300

Open EliCodesForFun opened 4 years ago

EliCodesForFun commented 4 years ago

I was wondering if it'd be possible to add in a setting/option where you can press the left or right arrow to scroll through the words (or characters) in a sentence, after mousing over the first word. I think this would be good for people trying to read thing while using a controller. Basically you could just mouse over the first word, then press the arrow keys to kind of read along. I think it could be pretty cool. Any thoughts?

siikamiika commented 4 years ago

I think it's a good idea. There's a collective issue for similar feature requests here: https://github.com/FooSoft/yomichan/issues/267

siikamiika commented 4 years ago

This could probably be done completely without mouse in caret browsing mode (works on Firefox with F7) together with https://github.com/FooSoft/yomichan/issues/161 using oncopy event together with document.execCommand('copy').

POC code:

window.addEventListener('copy', (e) => {
  const selection = document.getSelection();
  console.log(e, selection);
});

// (enter caret browsing mode and move the caret to some position)

document.execCommand('copy'); // gives target element, exact caret position and such
siikamiika commented 4 years ago

I have a POC branch for this feature. The first obvious issue I noticed was with focus on the popup, but that could probably be easily solved using postMessage. document.js could also need some updates, but I don't want to have conflicts with https://github.com/FooSoft/yomichan/pull/286.

oudajosefu commented 4 years ago

This feature should also be added on the search page to work with the sentence parser.