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

Add a pane in the dashboard (Firefox only) to assign keyboard shortcuts #106

Closed
5 of 8 tasks
jefferysmall opened this issue Jun 29, 2018 · 44 comments
Closed
5 of 8 tasks
Labels
enhancement New feature or request Firefox specific to Firefox fixed issue has been addressed

Comments

@jefferysmall
Copy link

jefferysmall commented Jun 29, 2018

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

I would like to see keyboard shortcuts added to allow the element picker and element zapper operations to be launched without the two-step process of opening the menu and then selection the desired operation. This would be especially useful and a time saver when working on a page where you want to block a series of elements.

So far as I can tell, uBO isn't supporting keyboard shortcuts at the moment.

A specific URL where the issue occurs

Steps to Reproduce

Expected behavior:

Actual behavior:

[What actually happened]

Your environment

  • uBlock Origin version: 1.16.8
  • Browser Name and version: Firefox 60.0.2
  • Operating System and version: Xubuntu 18.04
@uBlock-user
Copy link
Contributor

uBlock-user commented Jun 29, 2018

They were removed by gorhill after an issue was raised, see - gorhill/uBlock#2723 (comment)

@aplaice
Copy link

aplaice commented Jun 29, 2018

This is an issue with Firefox itself — there is no UI for reassigning webextension shortcuts:

https://bugzilla.mozilla.org/show_bug.cgi?id=1303384

uBlock Origin provides several "commands" (including entering element picker and element zapper mode) for which shortcuts could be assigned, but does not set any pre-defined shortcuts for them (AFAIK because these occasionally collided with various other, sometimes system, shortcuts and people complained...). Unfortunately this means that without support from the browser (i.e. Firefox) for changing/assigning shortcuts, you can't actually use them.

On Chrom(e|ium) shortcuts can be easily set, by going to chrome://extensions/shortcuts.

Bug on the old tracker: gorhill/uBlock#2870

There is, however, now an option for a webextension to reassign its own shortcuts (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/commands/update).

Potentially, uBlock Origin could work around the Firefox bug by providing a UI for reassigning its own shortcuts. Would a patch providing such support be considered (or is it out-of-scope for uBlock Origin)?

@uBlock-user
Copy link
Contributor

Duplicate of gorhill/uBlock#3473

@uBlock-user uBlock-user marked this as a duplicate of gorhill/uBlock#3473 Jun 29, 2018
@uBlock-user uBlock-user added the duplicate This issue or pull request already exists label Jun 29, 2018
@uBlock-user uBlock-user changed the title Fearure request: Add keyboard shortcuts for element picker and zapper Add keyboard shortcuts for element picker and zapper Jun 30, 2018
@jefferysmall
Copy link
Author

For whatever it's worth, the latest release of the Flagfox 6.1.0 just re-implemented user-customizable keyboard shortcuts.

  • Reimplemented support for customizable hotkeys for actions, instead of just one default (new WebExt API)

@gorhill gorhill changed the title Add keyboard shortcuts for element picker and zapper Add a pane in the dashboard (Firefox only) to assign keyboard shortcut Jul 10, 2018
@gorhill gorhill reopened this Jul 10, 2018
@gorhill gorhill changed the title Add a pane in the dashboard (Firefox only) to assign keyboard shortcut Add a pane in the dashboard (Firefox only) to assign keyboard shortcuts Jul 10, 2018
@uBlock-user uBlock-user added the Firefox specific to Firefox label Jul 10, 2018
@uBlock-user uBlock-user added the fixed issue has been addressed label Jul 19, 2018
gorhill added a commit to gorhill/uBlock that referenced this issue Jul 19, 2018
@uBlock-user
Copy link
Contributor

If those keys are already in use, it will not work.

@happysurf
Copy link

I have solved the problem with these shortcuts:
shortcuts

@uBlock-user
Copy link
Contributor

uBlock-user commented Jul 20, 2018

Ctrl+Shift+X and Ctrl+Shift+Z doesn't work on my end either, Ctrl+Shift+L works though.

@happysurf
Copy link

Ctrl+Shift+L works though.

Yes, exactly.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

If those keys are already in use, it will not work.

That's why Chromium's approach is nice, all shortcut assignments are centralized -- I really thought this was going to be addressed by Firefox as a priority.

Anyways, there are still things to address in the issue here:

@gorhill gorhill reopened this Jul 20, 2018
@uBlock-user
Copy link
Contributor

So why doesn't Ctrl+Shift+Z work? It's not in use unlike Ctrl+P

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

I don't know. Firefox probably returns an error when trying to assign it, I need to add code to catch that error.

Edit: "Ctrl-Shift-Z" works on my side (Linux/Nightly).

@uBlock-user
Copy link
Contributor

For the sake of argument, Ctrl+Shift+X doesn't work on my end also fyi

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Edit: "Ctrl-Shift-Z" works on my side (Linux/Nightly).

Aaaaaaand it stopped working. I can see the shortcut is properly set because uBO will query directly the commands API for the shortcuts and fill in the input fields. However, when I put a breakpoint into the command handler, it's not triggered. So this suggests an issue with Firefox itself.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Actually, Ctrl-Shift-Z is usually assigned to the Redo operation, so I suspect the key strokes are caught somewhere and never make it to uBO.

@uBlock-user
Copy link
Contributor

Debugged console log of the extension, if it is of any help -

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Issue is not uBO, Firefox never calls uBO with a lot of Ctrl-... shortcuts apparently. Maybe I should just forbid using Ctrl, because these are apparently ok to use, but they don't work as far as I can tell.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

I am going to have to reject "Ctrl" shortcuts, Firefox does not return an error when a shortcut is not going to be actually triggered for an extension. I looked at Flagfox and it also does not allow Ctrl-based shortcuts.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Using the browser toolbox, I can see Firefox is already defining a command for ctrl-shift-z => "redo":

a

For instance, I couldn't spot one for ctrl-shift-u in Firefox-defined commands, and as expected it worked with uBO.

Maybe it could be argued that there is something to fix on Firefox's side, i.e. that the commands.update API should return an error informing that a shortcut is reserved and already in use.

@aplaice
Copy link

aplaice commented Jul 20, 2018

In the case of the Shift-Alt-{letter} combinations, they seem to be recognised correctly if you press the keys in the order Alt, Shift, {letter}, but not in the order Shift, Alt, {letter}, and the same for Ctrl.

The lack of support for function keys beyond F12, is a Firefox (not uBlockOrigin) limitation:

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/commands#Shortcut_values

(Edit: Other than that, and the collision with in-built shortcuts, which is beyond uBlock's control, everything works great in 1.16.15b2.)

@jefferysmall
Copy link
Author

Yes, pressing Alt/Ctrl and then Shift does work when setting the shortcut, but you must also then press the keys in that sequence to execute the shortcut as well. This does not work if you want to use a Ctrl-Alt or Alt-Ctrl combination. Alt and Ctrl seem to be mutually exclusive. Also, the meta key doesn't appear to be available. This is all just user feedback, not an indication of a problem.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

These are all Firefox by-design behaviors, read the link posted above, we will have to live with these until they decide to centralize shrotcut assignement UI. I consider the issue fixed.

Keep in mind uBO's primary purpose is not to have a full-fledged over-complicated shortcut assignment UI. I observed the behavior of what exists in Chromium, and try to do as closed as can be without spending undue amount of time on this feature (a workaround due to lack of UI shortcut assignment in Firefox) which I was not originally planning to provide.

I will revised as needed when someone report back with information re. "Command key" above.

@gorhill gorhill closed this as completed Jul 20, 2018
@Betsy25
Copy link

Betsy25 commented Jul 20, 2018

There still is a minor issue with Azerty keyboards though, for example in the Shortcuts pane, trying to assign Alt-Z will enter Alt-W in the input & will react to Alt-W.

@gorhill gorhill reopened this Jul 20, 2018
@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Alt-Z will enter Alt-W in the input & will react to Alt-W

This needs fixing, I will look into it.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

I activated the French keyboard layout here (AZERTY), and the shortcuts were properly read (Linux Mint). So I can't reproduce.

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

@Betsy25 Can you tell me what is reported in this applet when you enter Alt-Z?

@Betsy25
Copy link

Betsy25 commented Jul 20, 2018

@Betsy25 Can you tell me what is reported in this applet when you enter Alt-Z?

Pressing Alt-Z on an Azerty keyboard gives me :
KeyboardEvent: key='Alt' | code='AltLeft'
KeyboardEvent: key='z' | code='KeyW'

@gorhill
Copy link
Member

gorhill commented Jul 20, 2018

Just to be sure... The physical key you pressed had "Z" on it?

@Betsy25
Copy link

Betsy25 commented Jul 20, 2018

Yep, on an Azerty keyboard, the physical keys pressed were "Alt" and "Z".

Physically pressing "Alt" and "A" gives me :
KeyboardEvent: key='Alt' | code='AltLeft'
KeyboardEvent: key='a' | code='KeyQ'

Win7 x64, Firefox Stable + Firefox Nightly.

@Betsy25
Copy link

Betsy25 commented Jul 21, 2018

I can confirm that the layout bug is fixed with the latest dev build.

@yourduskquibbles
Copy link

yourduskquibbles commented Jul 24, 2018

@gorhill It appears that if privacy.resistFingerprinting is set to 'true' in 'about:config' of Firefox v 61.0.1 it will prevent the shortcut keys from being able to be set.

It seems that once the key binding is set by setting privacy.resistFingerprinting to 'false', the shortcuts will continue to work regardless of the privacy.resistFingerprinting is set as 'true' or 'false'.

I looked over the bugzilla issues you posted in this thread and didn't see it brought up and I'm really not sure if this is a firefox bug or uBlock Origin bug so wanted to bring it to your attention.

@gorhill
Copy link
Member

gorhill commented Jul 24, 2018

uBlock Origin has no knowledge of that flag, it merely just calls browser.commands.update(), there is nothing more for uBO to do to assign shortcuts. That resistFingerprinting flag is not officially supported by Firefox, use at your own risk.

@GuardianMajor
Copy link

@gorhill Forgive me if I am being dense here, but I don't see that tab, did I miss a special consideration that would make it appear?

@aplaice
Copy link

aplaice commented Jul 25, 2018

@GuardianMajor What version of uBO do you have installed? (The current latest version on AMO is 1.16.14, while the added functionality is only in version 1.16.15(x), which you can download from GitHub.)

(Also see above.)

@gorhill
Copy link
Member

gorhill commented Jul 25, 2018

You need uBO 1.16.15b? and Firefox 60+, the API needed to dynamically assign shortcuts (commands.update) became available with FF60.

@GuardianMajor
Copy link

@aplaice I have the latest beta which is what I always run directly from GitHub.

@gorhill Yes, figured that was a given, why else would I know it was meant to be there 😄 But the last part is helpful, thank you, I will check but I think this particular browser version might not have it.

@jefferysmall
Copy link
Author

Asked above, but it might have been lost in the noise:

Any chance of adding a shortcut to open the Dashboard as there is with the logger?

@LiCybora
Copy link

The current keyboard shortcut pages not work for Apple Mac Keyboard layout.

  1. Press 'Command' having no response (There is no catcher for Command Key in 'shortcuts.js').
  2. Press 'control' which able to record shortcut, but unable to call. (Because Mac treat 'Ctrl' as 'Command')
  3. Press 'Alt', but unable to bind with any other key. (Because in Mac, Alt+P will type π, but there is no catcher of π in 'shortcut.js')

I do not listen to MacOS-specific key press. I will need someone with MacOS to report to me what is the key & code names for the "Command" key.

I have a quick hack to make things work. Here maybe what you want @gorhill ?
https://github.com/gorhill/uBlock/compare/master...LiCybora:uBlock-master?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Firefox specific to Firefox fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

9 participants