wshanks / Zutilo

Zotero plugin providing some additional editing features
Other
1.51k stars 72 forks source link

Missing conflict with Zotero Quick Search bar shortcut #238

Closed raffaem closed 2 years ago

raffaem commented 2 years ago

CTRL+SHIFT+K is Zotero's built in focus on the quick search bar.

But if you assign a command to it, Zutilo misses the conflict.

qqobb commented 2 years ago

CTRL+SHIFT+K is Zotero's built in focus on the quick search bar.

Yes, Zotero's default shortcuts for Quick Search are Ctrl+Shift+K and Ctrl+F. (BTW, there's also a new shortcut for Advanced Search: Ctrl+Shift+F.) If you want to use Ctrl+Shift+K for another function in Zutilo, you could change Ctrl+Shift+K to a dummy value like Ctrl+Shift+Δ in the Advanced pane of Zotero's preferences. You'll still be able to use Ctrl+F for Quick Search.

But if you assign a command to it, Zutilo misses the conflict.

Currently, Zutilo doesn't check for conflicts with Zotero's shortcuts. This would clearly be desirable, but it's not straightforward. I'll close this issue as it's a duplicate of #77.

Some of Zotero's shortcuts are listed here, but this list keeps changing and isn't complete. As far as I know it isn't accessible in a programmatic form. It would be nice if Zotero could provide something like the keyboard shortcuts editor in Visual Studio Code.

raffaem commented 2 years ago

Currently, Zutilo doesn't check for conflicts with Zotero's shortcuts.

Sorry, I didn't get this screen then:

image

raffaem commented 2 years ago

I also didn't get the point of noConflictingKeys function at line 203 of addon/chrome/content/zutilo/keyconfig_adapted.js :)

qqobb commented 2 years ago

Zutilo checks for conflicts with other Zutilo shortcuts. This doesn't work for Zotero shortcuts.

To print out Zutilo's keyboard shortcuts, go to "Tools" -> "Developer" -> "Run JavaScript", and paste in and run this code:

// Zutilo keyboard shortcuts
var msg = `Current Zutilo keyboard shortcuts:\n\n`;
var keyset = document.getElementById("zutilo-keyset");
var keyLabels = [];
var keyValues = [];
for (let child of keyset.children) {
    if (child.getAttribute("key")) {
        let label = child.id.replace(`zutilo-key-`,'');
        keyLabels.push(label);
        let modifiers = child.getAttribute("modifiers");
        let key = child.getAttribute("key");
        let keycode = child.getAttribute("keycode");
        keycode = (keycode === "") ? null : keycode;
        let value = {"modifiers":modifiers,"key":key,"keycode":keycode};
        value = JSON.stringify(value);
        keyValues.push(value);
        let name = Zutilo.getString(`zutilo.shortcuts.name.` + label);
        msg += `Name: "${name}"\nLabel: ${label}\nValue: ${value}\n\n`;
    }
}
raffaem commented 2 years ago

This is what I get:

image

And when I go to Tools->Zutilo Preferences->Shortcuts, I see all shortcuts disabled, except for "Items pane: Focus" shich is mapped to CTRL+SHIFT+J.

If I click on a random item, and try to map it to CTRL+SHIFT+A, and click Apply, this is what I get:

image

Although there is no such shortcut on Zutilo: they are all disabled except one, and your Javascript code doesn't show this shortcut anyway.

qqobb commented 2 years ago

You're right, it works for some Zotero shortcuts, but not all. It depends how Zotero is creating these shortcuts. The shortcuts here including copyCitation are taken into account by Zutilo, but the shortcuts here including quicksearch are not. There are also shortcuts for Zotero's PDF reader that aren't taken into account, e.g. Ctrl+0 for automatic zoom.

I'm not sure if there's a good way for Zutilo to check for conflicts with the latter Zotero shortcuts, but it's worth looking into it, which will be tracked in #77. The issue of keyCode and charCode instead of key might also be relevant here, see https://github.com/wshanks/Zutilo/issues/76#issuecomment-665032338.

wshanks commented 2 years ago

Zutilo's shortcut code was taken from a separate old Firefox/Thunderbird XUL extension called Keyconfig. It tests the built-in (XUL) shortcuts. It doesn't check shortcuts that are implemented another way, like with a key event listener (I didn't check but this might be how the configurable ctrl+shift Zotero shortcuts are implemented). It makes sense to check for conflicts with them as well, but that would need to be added on. I haven't looked at the code to see if there is a better way but this might come down to having the names of the shortcut preferences hardcoded into Zutilo and looping over and checking them.