Simple extension request

I would like a simple extension that whenever I press the grave accent key (backwards single quote), the current tab is closed.

Can anyone write that for me?

1 Like

It is easy to make the extension… however, since the WebExtension API does not allow easy reassignment of the keyboard shortcuts, it will have very limited use (you only).

On the other hand, many people need and use the back-tick (grave accent) for content and closing the tab will not be welcomed.

1 Like

Yes, use would be limited. But if it’s easy to make, I would sure appreciate it!

Due to its limited use, it would be rejected by AMO and be asked to self-host the addon unless you are using Dev Edition, Nightly or Unbranded version of Firefox where you can have unsigned addons.

Didn’t the built-in shortcuts help?

https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly

I can use dev edition, nightly, or unbranded.

I need a single key to close the current tab; a key combination does not work for my needs.

Thanks for your understanding.

OK… Let me see… I will make a minimal extension that you can install.

There seems to be a limitation on the keys that can be used and back-tick (grave accent) isn’t one of them

key (mandatory). This can be any one of:
the letters A-Z
the numbers 0-9
the function keys F1-F12
Comma, Period, Home, End, PageUp, PageDown, Space, Insert, Delete, Up, Down, Left, Right

Media keys
Alternatively, the shortcut may be specified as one of the following media keys:

"MediaNextTrack", "MediaPlayPause", "MediaPrevTrack", "MediaStop"

Thanks!

According to https://developer.mozilla.org/Add-ons/WebExtensions/manifest.json/commands it looks like a modifier is required for everything except for function keys. If so, that’s really limiting.

So I guess it will have to be F1 to close a tab.

BTW, in XUL, things were very versatile. Here is what I wrote for XUL:

<keyset id="mainKeyset">
  <key key="`" oncommand="BrowserCloseTabOrWindow();"/>
  <key keycode="VK_F1" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);"/>
  <key keycode="VK_F2" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"/>
</keyset>

What I would like is the same thing in WebExtensions, but it looks like the API is too restrictive.

BTW, take a look at https://addons.mozilla.org/firefox/addon/videospeed/

It uses WE, and is able to allow the user to change hotkeys. Can you use a similar technique? I’m guessing not since that extension does not use global hotkeys, but you would know better than I.

Anyways, if I have F1 to close the current tab, that would be a decent second choice after back-tick.

Since F8 and F9 aren’t used by Firefox, if you could have them go to the previous (F8) and next (F9) tabs, that would be incredible. When I say previous and next tabs, I’m referring to the order in the tabbar, as opposed to the order last accessed (like ctrl+tab).

Thanks for your help!

Yes… but that is a hack but adding listeners to every page (needed or not). It can cause conflict with listeners on the page.

That can be done.

That would go beyond a basic addon.

Yes… but that is a hack but adding listeners to every page (needed or not). It can cause conflict with listeners on the page.

Would you recommend not using that extension due to that concern?

Does that technique slow down browsing?

That can be done.

Sounds great. Looking forward to it whenever you have the time! TIA.

That would go beyond a basic addon.

Ah, so there’s nothing like a simple

tabContainer.advanceSelectedTab(1, true)

in the WebExtensions API?

Either way, keeping it simple sounds good.

Here it is: https://github.com/erosman/tabkey

Download it as zip, change the extension to xpi and install (Dev, Unbranded or Nightly allow unsigned extension)

That works a treat! So excellent.

Thank you.

If you’re on Windows you can also use AutoHotkey to customize your keyboard shortcuts without having to use a custom add-on.