wshanks / Zutilo

Zotero plugin providing some additional editing features
Other
1.5k stars 71 forks source link

Single-key shortcuts are settable but not working #122

Open stefanct opened 4 years ago

stefanct commented 4 years ago

I am not sure if my problem is related to #76 but I don't think so. I am also a Zutilo n00b (but CS professional).

My setup: Debian Buster with Mate Zotero 5.0.82 Zutilo 3.3.3 Additional Zotero plugins: better bibtex, doi manager, zotfile

Zotero's native shortcuts work fine (and do not conflict with what I tried in Zutilo). I was trying to set up the Zutilo shortcuts for the first time and could not get any to work at all first. With some systematic testing I was able to determine that primarily the shortcuts using a single do not work, e.g., exercising function keys. I have been using function keys as shortcuts for extensions in Firefox in the past so I assume this is not a fundamental issue with the engine but I have not tried to dig into the code at all.

Below are my test results. If not noted otherwise the keyboard input in the settings recognize the keys just fine.

Not working:

Working:

wshanks commented 4 years ago

As your findings indicate, ctrl, alt, and shift should work pretty well. It is not surprising that the win and altgr keys do not work. The code only explicitly handles alt, ctrl, meta (command on macOS) and shift. The os modifier (corresponding to the win key) is also listed in the documentation but there it says it is not recommended to use it.

I have not studied how the OS handles modifier keys in a while. It might be possible to map AltGr to what Zotero/Firefox thinks is the meta key on Linux (if it thinks the meta key is anything on Linux).

In my testing, esc and the function keys did not work either. They are recognized in the Zutilo preferences entry box but do not work when used. I think outside of the preferences window they might be captured at a higher level by Gecko/Firefox than the shortcut system. VK_PAUSE might be similar. ^ did work for me though (it was recognized as shift+^).

You say that these keys worked in the past. What extensions were you using them with? Zotero bumped its version of Firefox recently (around Zotero 5.0.75 it jumped from Firefox 52 to Firefox 60). It is possible these keys worked in the past with an older version of Firefox.

For what to do about this...I guess the options are:

  1. add better documentation of keys that do not work
  2. compile a list of keys that do not work and give feedback in the preferences window instead of acting like they will work
  3. try to make the keys work

I lean towards option 1 because I don't have a lot of time to do 2 or 3. 2 might not be too bad to do. My main concern would be disabling keys that might work on a different system than the one I tested on. I think 3 might be impossible or would require rearchitecting how the keyboard shortcuts are implemented. I have been avoiding architectural changes since Zotero announced plans to switch to an Electron base since I anticipate that will require architectural changes again.

stefanct commented 4 years ago

I don't really care about the multi-key shortcuts for my personal use case. I just mentioned them because I've been testing them anyway.

I have not used single-key shortcuts successfully in Zotero and/or Zutilo in the past (just to make that absolutely clear). But I am actively using F1 in my browser/FF 68 (and with older versions but I cannot trivially determine which of them, whatever was in Debian Buster over the last year+). I am using it to toggle the visibility of the sidebar (for vertical tabs): https://github.com/piroor/treestyletab/ AFAICT TST uses https://github.com/piroor/webextensions-lib-shortcut-customize-ui for the key handling.

If you don't have time to take a look at how TST does it (or if that's too much work to implement) then I agree that disabling any keys because of a black list is a bad idea (giving a hint/warning would be the best option if there is no fix though IMHO). After all, it might some day just work :)

wshanks commented 4 years ago

The shortcut library you link to uses the WebExtensions commands API which is the only way to register shortcuts in Firefox 57+ (when legacy XUL addon support was dropped). I have not experimented with that API inside of Zotero. I am not sure if it is functional in Zotero. I don't think it is worth looking into unless the Zotero developers say that they plan to use that API for extensions in the Electron base because even if the WebExtensions API were included in the new versions of Zotero I think its sandboxing features would isolate it from interacting with Zotero's internals. Zutilo works now by just calling functions from Zotero's internals which is the old XUL-style of Firefox addons.