lydell / LinkHints

A browser extension that lets you click with your keyboard.
https://lydell.github.io/LinkHints
MIT License
153 stars 8 forks source link

Open hint in new window #54

Open ceasal opened 2 years ago

ceasal commented 2 years ago

Note from @lydell

This has been partially implemented – see https://github.com/lydell/LinkHints/pull/55

If you use this feature, feel free to 👍 this issue, and leave a comment if you have any feedback.

Problem

If I press Ctrl + Shift when I have a link highlighted or Shift when I click a link in Firefox, it opens in a new window. As far as I can tell, Link Hints does not offer a way to remap / disable the "hold shift to search link text" while in link hinting mode so that I could perform Firefox's built in method of opening a tab in a new window.

Suggestion

Add a way to remap / disable "hold shift to search link text" while in link hinting mode or add a mapping that would open a chosen hint in a new window.

lydell commented 2 years ago

Hi! I thought about window commands when I initially wrote the extension, but decided to avoid them completely (since I don’t need them myself) until someone requests them. Now’s the time!

One thing that made me be unsure was “knowing when to stop”. I could imagine all of these actions:

Also, it’s hard to come up with good default keyboard shortcuts that are available. (One option is to not provide any default keyboard shortcuts for window commands, since it seems like most Link Hints users don’t need them.)

To better understand what you need, could you provide some more info?

  1. How do you use tabs and windows? Working on another extension, I’ve met people who used tiling window managers and didn’t use tabs at all – only windows. Do you use both?

  2. If Link Hints had a checkbox option that changed the current commands for opening links in foreground/background tabs into opening foreground/background windows instead, how would that work for you? In other words, “trading tabs for windows” basically?

  3. How often do you open links in new windows? If it’s rare, you could use Ctrl + Shift + L to focus the link, and then use the standard Ctrl + Shift + Enter (or whatever it is) to open the link in a new window. (Vice versa if you use tabs rarely.)

  4. Is there a reason you suggested holding modifier keys in the already existing hint modes, rather than new commands?

    • One can already hold Alt when typing the last hint letter to force links to open in a new tab. So I get that it could make sense to press some other combination to force a new window! And it could avoid having so many modes. However, I afraid there’s no modifier (or modifier combination) available for use. Ctrl does not work generally enough for Web Extensions – for exampple, Ctrl + W always closes the current tab, no matter what. Alt + Shift changes which character is typed, making it very complicated to know if a hint matches or not. The Windows key isn’t usable in Web Extensions, and the OS wins. Maybe Alt + Ctrl? But that probably wouldn’t work well on macOS, since Alt/Option is used to type special characters. And Alt + Ctrl means AltGr on European keyboards on Windows, right? There are a lot of factors to take into account here: OS (Windows, macOS, Linux) shortcuts, keyboard layouts, Web Extensiion limitations.

    • Note: I’m not completely sold on the idea of “sacrificing” the “filter by text” feature for window capabilities. I’d rather find something where both can work at the same time.

    In summary – I rarely use more than one window myself, so my motivation is a bit low on this feature. But if we can come up with some nice simple solution there might be a chance of getting it!

ceasal commented 2 years ago

One thing that made me be unsure was “knowing when to stop”. I could imagine all of these actions:

* Open link in background window

* Open link in foreground window

* Open link in private window (background and foreground as well?)

* Open link in another already existing window somehow?

To my understanding, Firefox simply opens a link in a new window, and it is the job of the window manager the user runs to to open said window in the foreground / background / in another workspace / etc.

1. How do you use tabs and windows? Working on another extension, I’ve met people who used tiling window managers and didn’t use tabs at all – only windows. Do you use both?

I use a tiling window manager and do not use tabs at all. I used tabs for a long time, but find that using windows has 2 benefits to me.

  1. I keep less windows open at once than tabs.
  2. I can leverage the same keybinds I use to manage windows.
2. If Link Hints had a checkbox option that changed the current commands for opening links in foreground/background tabs into opening foreground/background windows instead, how would that work for you? In other words, “trading tabs for windows” basically?

I only use windows, so that would work in my case. It may not if someone wants both.

3. How often do you open links in new windows? If it’s rare, you could use `Ctrl + Shift + L` to focus the link, and then use the standard `Ctrl + Shift + Enter` (or whatever it is) to open the link in a new window. (Vice versa if you use _tabs_ rarely.)

That was the solution I found after a bit of messing about. It's an extra keypress to focus and then open, though, and feels awkward given how often I open new windows.

4. Is there a reason you suggested holding modifier keys in the already existing hint modes, rather than new commands?
  1. It makes use of Firefox's existing keybinds.

    Given that I can already perform the desired behavior in Link Hint's selection mode (Ctrl + Shift + L), I concluded that this behavior must possible in other modes if those modes do not map the Shift key.

  2. Link hints provides the Alt modifier already to open a link in a new tab from Alt+J.

* One can already hold `Alt` when typing the last hint letter to force links to open in a new tab. So I get that it could make sense to press some other combination to force a new window! And it could avoid having so many modes. However, I afraid there’s no modifier (or modifier combination) available for use. `Ctrl` does not work generally enough for Web Extensions – for exampple, `Ctrl + W` _always_ closes the current tab, no matter what. `Alt + Shift` changes which character is typed, making it very complicated to know if a hint matches or not. The Windows key isn’t usable in Web Extensions, and the OS wins. Maybe `Alt + Ctrl`? But that probably wouldn’t work well on macOS, since Alt/Option is used to type special characters. And `Alt + Ctrl` means `AltGr` on European keyboards on Windows, right? There are a lot of factors to take into account here: OS (Windows, macOS, Linux) shortcuts, keyboard layouts, Web Extensiion limitations.

The choice of modifier key seems tough, then--an easy solution would be to avoid a new modifier and instead offer a mode like Ctrl+J but that opens the selected hint in a new window, similar to Ctrl+K for opening in new tab.

lydell commented 2 years ago

I’ve released 1.3.0 with the hidden option (it will take a little time before it appears in the Chrome Store though), but I’ll keep the issue open since the feature isn’t 100 % and to see if other people use windows as well.