traxium / tabtree

Tab Tree extension for Firefox
https://addons.mozilla.org/en-US/firefox/addon/tab-tree/
GNU General Public License v3.0
144 stars 30 forks source link

[Feature request] Set hotkeys for tab movement/creation commands #144

Open duncanMR opened 8 years ago

duncanMR commented 8 years ago

Thanks for a fantastic addon! I'm using it with VimFX, and one issue is that TabTree doesn't seem to allow setting hotkeys for any of its tab creation/movement commands (like make child tab). So it doesn't work too well with the keyboard-driven style of browsing. There is an option for setting hotkeys in the menu but it seems to be non-functional. Is there some hook I could use to make hotkeys, perhaps to add to my vimfx/config.js?

roryokane commented 7 years ago

Hotkeys are currently defined starting at line 1140 of bootstrap.js. Most of the key combinations are hard-coded, directly referencing keyboard keys like this:

} else if (keyboardEvent.ctrlKey && keyboardEvent.altKey && keyboardEvent.shiftKey && helper.testKey('PageDown', 'pagedown')) {
    // #68 Ctrl+Alt+Shift+PageDown - slow moving speed:

One of the key combinations, F8 for hiding and showing the tab sidebar, is configurable:

} else if (helper.testKey(Services.prefs.getCharPref("extensions.tabtree.auto-hide-key"), Services.prefs.getCharPref("extensions.tabtree.auto-hide-key").toLowerCase())) {
    // #40 #80 F8 toggles 4 auto-hide options:

You couldn’t just use helper.testKey(Services.prefs.getCharPref(…)) everywhere to make the other hotkeys configurable. That strategy doesn’t allow you to configure what modifier keys (keyboardEvent.ctrlKey, etc.) are held down along with the key.

Storing and reading desired modifier key states from an extensions.tabtree.* preference could be implemented by serializing and parsing key combinations to an object. For example, the string value "Alt+Shift+PageUp" could be converted to {requiresAlt: true, requiresShift: true, requiresCtrl: false, key: "PageUp"}, and that object could then be used to perform the appropriate checks on keyboardEvent. Or it could be implemented more simply but more hackily with a multitude of preferences for each hotkey, such as extensions.tabtree.auto-hide-key (string), extensions.tabtree.auto-hide-key-ctrl (boolean), etc.

roryokane commented 7 years ago

See also: #49 – [Feature] Customizable keyboard shortcuts