brookhong / Surfingkeys

Map your keys for web surfing, expand your browser with javascript and keyboard.

Home Page:https://chrome.google.com/webstore/detail/surfingkeys/gfbliohnnapiefjpjlpjnehglfpaknnc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: implement Vimium-style insert mode

gibfahn opened this issue · comments

First off, thanks for this extension, it has a laundry list of features that I haven't found in any other addon.

It would be really useful to have something like the i insert mode mapping in Vimium. It's similar to the disable plugin hotkey, but it's more useful in websites that already have good keyboard shortcuts.

The difference is that it that it's implemented as a mode, so:

  • It's faster
  • It doesn't persist between pages on the same domain, or if you reload the tab.
  • You can see that you're in Insert mode (from the status bar).
  • You can disable it with Esc, so you can always use Esc to get back to Normal mode.

For example in YouTube or Gmail, I want to always start with SurfingKeys on, but easily drop into the web-page keyboard shortcuts when I want to use the Keyboard Mappings for the media controls, or the email selection. The Insert analogy works well because it's similar to wanting to edit a textbox.

Some discussion of how the feature is used at philc/vimium#314 (although the issue isn't actually about that).

You could keep only specified keys from Surfingkeys on specified sites as below,

// only keep E, R and T from Surfingkeys for gmail.com and twitter.com
unmapAllExcept(['E','R','T'], /gmail.com|twitter.com/);

In that way, you need not enter any mode to use wanted short-cuts both from Surfingkeys and the page itself.

You could use your own regex for the second parameter to extend sites.

#547

Yeah, I've tried that, problem is that there are loads of hotkeys used in both. Also it doesn't scale when you have a large number of pages that you'd need to manually update.

Gmail:

image

Youtube:

image

Alt-s to toggle Surfingkeys, actually does what you proposed.

It's faster

Yes, only Alt-s.

It doesn't persist between pages on the same domain, or if you reload the tab.

This is a little different, the switch persists on same domain, but another Alt-s will bring Surfingkeys back.

You can see that you're in Insert mode (from the status bar).

Yes, it is actually a mode (called Disabled), another Alt-s will exit from it. The difference here is that Surfingkeys does not show it in status bar by default, it grays the Surfingkeys icon in toolbar.

You can disable it with Esc, so you can always use Esc to get back to Normal mode.

The difference here is Surfingkeys uses Alt-s rather than Esc.

Alt-s to toggle Surfingkeys, actually does what you proposed.

I agree there's not a huge difference, but I would argue that it's significant (I'm currently using Alt-s).

It's faster
Yes, only Alt-s.

Let's forget speed for now, it's not that much slower, and maybe it's just my imagination 😁 .

This is a little different, the switch persists on same domain, but another Alt-s will bring Surfingkeys back.
The difference here is Surfingkeys uses Alt-s rather than Esc.

Yes, the fact that it's per-domain, and the fact that it's toggled, make it much harder to use in my experience.

Here's my flow with Vimium:

  • Switch to tab
  • Press Escape a couple of times
  • Ready (I know I'm in Normal mode and not visual or insert)

Here's my flow in SurfingKeys:

  • Switch to tab
  • Press Escape a couple of times (I could be in Visual on insert mode)
  • Try the thing I want to do, it doesn't work because I'm in disabled mode
  • Check the icon to see whether it's blue or grey (hard to tell in my browser)
    image
    image
  • Press Alt-s
  • If I got it wrong I've now disabled SurfingKeys, so I have to check and press Alt-s again.
  • Ready

My ideal would be a non-persistent disabled mode that is per-tab, and that can be turned off (not toggled) with Esc. For me Vim is fast because you don't need to check your status, you just press Esc and go.

Alt-i to enter PassThrough mode to temporarily suppress SurfingKeys.

New mode PassThrough exported for this since 0.9.25.

Wow, that completely meets my needs, and is better than the Vimium equivalent, thanks a lot!

I like PassThrough mode, thanks @brookhong! I agree that I prefer it to the Alt-s disable.

I would even like to take it one step further, and have a command to enable PassThrough mode for just a single keystroke. This is like vim's r command (for "replace") which is like "[s]ubstitute" mode but for just a single character. I would bind the command to r and use it for accessing a site's built-in keyboard shortcuts without disabling anything, i.e. re on GitHub to edit a file, or r. in Jira or Bitbucket to open the commands menu.

I would even like to take it one step further, and have a command to enable PassThrough mode for just a single keystroke. This is like vim's r command (for "replace") which is like "[s]ubstitute" mode but for just a single character.

Yeah I have it bound to p.

map('p', '<Alt-i>'); // Map p to toggle passthrough mode.

@gibfahn I'm not 100% sure but I think @jbyler was not talking about shortening the keyboard shortcut for passthrough mode, but instead suggesting a different way of enabling a passthrough mode which is non-sticky, i.e. it automatically quits after passing a single keystroke through to the page. @jbyler is that right? If so, I think it's a great idea and recommend submitting a separate issue for that feature request.

@aspiers Yes, your paraphrase matches my intent: a non-sticky passthrough, which only passes a single keystroke and then quits. I filed issue #964 to track this idea.

Thanks again for making a great extension!