Coder Social home page Coder Social logo

Comments (5)

ken107 avatar ken107 commented on June 16, 2024 1

The behavior of the right-click context menu is a bit special. When you right click on the selection, the browser grabs the selected text and hands it directly to our context-menu event handler to read aloud. This is different from the other activation methods, which has to inject code into the page to grab the selected text.

For this reason, we can't make a keyboard shortcut that replicate the exact equivalent behavior. Our keyboard handler will hvae to inject code to grab the text. But the "Play/Pause" and "Activate the extension" shortcuts are already doing that.

Now since you don't want to popup to appear, you are left with the "Play/Pause" method. Your issue is you want the shortcut to start reading anew instead of pausing. Unfortunately Chrome only allows maximum 4 keyboard shortcuts. We cannot add another one without removing something.

A workaround you can use right now is to press the Stop shortcut first, and then the Play/Pause shortcut. But this leads me to this train of thought. Maybe we can change the "Play/Pause" shortcut to just "Play", and make it always play anew. Then change the "Stop" shortcut to "Pause/Resume". After all, the user doesn't care about the distinction between pause and stop. Let me think more about this.

from read-aloud.

nhan000 avatar nhan000 commented on June 16, 2024 1

Unfortunately Chrome only allows maximum 4 keyboard shortcuts.

Oh that explains why most extensions I see only have that many shortcuts. However, there're also many other plugins that allow more than 4 shortcuts (uBlock Origin — 7, Global Speed — 16), Tweaks for YouTube — ~ 20)

My current work around is exactly as you said — to use Stop and then Play. Your proposal to change around these shortcuts make sense to me. If there's difficulty choosing what functions to give to a shortcut, I'd recommend you to look at Global Speed. I really like how it allows users to really deeply customize its shortcuts.

The work around though doesn't work with selected text from pages such as https://www.autohotkey.com/docs/v2/Program.htm. But right click → Read aloud selected text work.

Btw, I have a somewhat related request: Is there a way to for the plugin to read aloud the clipboard content? I'm thinking if I can be in any app, copy text, and then use a global shortcut to have this extension read that block of text aloud. Let me know if I should make a separate feature request. This would also help with reading selected text from the autohokey page above (select text → copy → read instead of right click and select the Read aloud option). Thank you!

from read-aloud.

ken107 avatar ken107 commented on June 16, 2024 1

Ah thank you, I had the wrong assumption about the 4-shortcut limits. So we can have as many shortcuts defined as we want, but only 4 active at any one time, I suppose. I'll see what shortcuts to add that makes sense.

The behavior of the right-click context menu is a bit special. When you right click on the selection, the browser grabs the selected text and hands it directly to our context-menu event handler to read aloud. This is different from the other activation methods, which has to inject code into the page to grab the selected text.

On sites like autohotkey.com, the regular activation method is unable to grab the selected text because the selection is inside in iframe. Technically we could traverse all the frames and find which one has text selected, but if the frame is cross-domain, we won't be able to access it. In that case, only the right-click method will work.

from read-aloud.

ken107 avatar ken107 commented on June 16, 2024 1

Ah, you're right. Users can set as many as they want. Indeed only 4 can be declared by the extension.

from read-aloud.

nhan000 avatar nhan000 commented on June 16, 2024

but only 4 active at any one time

I've had 5 active shortcuts from an extension, so there can be more active shortcuts :D

from read-aloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.