Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Command to pass a single keystroke through to the page #964

Closed
jbyler opened this issue May 14, 2019 · 7 comments
Closed

Comments

@jbyler
Copy link

jbyler commented May 14, 2019

Prelude

Some web sites implement their own keyboard shortcuts. For example, on GitHub you can focus the search bar by typing 's' or '/'. Or while viewing a file (e.g. Surfingkeys/README.md), you can hit the 'b' key to jump into blame mode. (See GitHub's page Using keyboard shortcuts for a full list.)

Surfingkeys by its nature occupies a lot of keys on the keyboard, and most of the time it precludes using a web site's own keyboard shortcuts, if any.

Existing Workarounds

PassThrough Mode helps here:

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

So a user on GitHub can enter Alt-i s Alt-i to access the search bar.

But I think we can improve on this experience by implementing a single-keystroke passthrough mode.

Proposal

Add a command and to Surfingkeys which enables PassThrough mode, but only for a single keystroke, and bind it to the r key. That way a user on GitHub can access the search bar just by typing rs.

Alternate Proposal

Or, perhaps instead of passing a single keystroke, this new command should enable PassThrough mode, then wait for the next keystroke, and then an additional timeout—say, 300ms—before disabling PassThrough mode. That would allow easy access to web sites with multi-key shortcuts, like GitHub's gp for "Go to pull requests tab". Under this alternate proposal, a user could type rgp to access the pull requests tab.

This alternate proposal might be nice or it might be too complicated and thus finicky; I guess if someone implements it they will need to experiment a bit to see how well it works.

Prior Discussion

For reference: there was some discussion on Issue #656 about this idea, including a proposal for it in this comment, and then a request from @aspiers in this later comment for a ticket to track the idea. Hence this ticket.

@aspiers
Copy link
Contributor

aspiers commented May 14, 2019

Great feature request, although r is already taken by "reload page". However p is not taken by anything yet, and that's an even better choice because it's a mnemonic for "pass-through".

@aspiers
Copy link
Contributor

aspiers commented May 17, 2019

Also, I'd like to register my +1 vote for the alternate proposal, because without support for multi-key shortcuts, this feature would not be very useful on several sites, including many of Google's which tend to support multi-key shortcuts.

To add a little bit of detail to this alternate proposal:

  • 300ms sounds like a good default timeout, but it should be configurable.
  • There would need to be a clear visual indicator of when this ephemeral pass-through mode is enabled.
  • I think the timeout should be reset each time the user presses a key, e.g.:
    • User presses p => timeout clock starts ticking
    • User presses g within the timeout => g is sent to the web site and the clock is reset to 0 but immediately starts ticking again
    • User presses p within the timeout => p is sent to the web site and the clock is reset to 0 but immediately starts ticking again
    • User starts reading pull requests for more than 300ms (actually in this example, it would typically take more than 300ms for the new page to load), so the timeout is exceeded, and this ephemeral pass-through mode is automatically disabled.

This would also allow pass-through of 3 or more keystrokes if typed quickly enough.

@dwiel
Copy link

dwiel commented Oct 15, 2019

This feature would be super helpful as a user of voice control software. As a keyboard user, modes are helpful in cramming a large number of actions onto a limited set of keys, but when controlling the computer by voice this constraint is no longer present and modeless operation is often preferred.

This feature would make it easier to expose actions on the tab (to either the browser via surfingkeys or to the page via pass through) in a way which does not require the voice automation code to know the current state of the browser tab.

@brookhong
Copy link
Owner

A new flag -- settings.passThroughTimeout is introduced in 0.9.49, which is for automatical quit from PassThrough mode after specified milliseconds, to set it 0 will disable automatical quit.

The idea basically came from proposal of @aspiers, but I implemented it with a settings flag instead of a new mode. If settings.passThroughTimeout was set to 0(by default), PassThrough works as before. If it is set to a positive number, PassThrough mode will automatically quit after specified milliseconds, you could try add below into your settings:

settings.passThroughTimeout = 1000; // automatically quit PassThrough mode after 1 second.

then press <Alt-i>? on this page, it will display the built-in help from github.

@aspiers
Copy link
Contributor

aspiers commented Nov 1, 2019

Thanks, this is great! Although I would have preferred a separate mode, because sometimes I want a semi-permanent passthrough, and other times just for one command.

I tried this:

mapkey('<Alt-i>', '#0enter PassThrough mode to temporarily suppress SurfingKeys', function() {
    settings.passThroughTimeout = 0; // never automatically quit PassThrough mode
    Normal.passThrough();
});
mapkey('p', '#0enter PassThrough mode to temporarily suppress SurfingKeys', function() {
    settings.passThroughTimeout = 1000; // automatically quit PassThrough mode after 1 second.
    Normal.passThrough();
});

but it didn't work :-(

@brookhong
Copy link
Owner

I refined the implementation, p comes as default for ephemeral passthrough mode. Please see https://github.com/brookhong/Surfingkeys/blob/master/pages/default.js#L263

Hope that helps.

@aspiers
Copy link
Contributor

aspiers commented Nov 7, 2019

Works fantastically, thank you so much! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@dwiel @aspiers @brookhong @jbyler and others