gilmoreorless / chrome-new-tab-here

A shortcut to open a new tab next to the current one in Chrome
https://chrome.google.com/webstore/detail/open-new-tab-here/kpoogeanhkgkbkagbgeibbokbjdbjodb
MIT License
10 stars 1 forks source link

Support for additional modifiers and non-letters keys #2

Open msva opened 2 years ago

msva commented 2 years ago

Hi there!

1) It wold be nice to support additional modifier keys such as Alt and Super (aka winkey), and not only current set of Ctrl and Shift. 2) also, I found that plugin also requires keys to be "letters", and don't want to take, say, [/] keys (althought, it took . :shrug:)

gilmoreorless commented 2 years ago

Hi, thanks for the suggestions.

Unfortunately, the restrictions for keyboard shortcuts are defined within Chrome itself, not by individual extensions. The current requirements can be found at https://developer.chrome.com/docs/extensions/reference/commands/#key-combinations. The available set of modifier keys depends on the operating system:

  • Extension command shortcuts must include either Ctrl or Alt.
    • Modifiers cannot be used in combination with Media Keys.
  • On macOS Ctrl is automatically converted into Command.
    • To use the Control key on macOS, replace Ctrl with MacCtrl when defining the "mac" shortcut.
    • Including MacCtrl in other shortcuts will cause the extension to be uninstallable.
  • Shift is an optional modifier on all platforms.
  • Search is an optional modifier exclusive to Chrome OS.
  • Certain operating system and Chrome shortcuts (e.g. window management) always take priority over Extension command shortcuts and can not be overwritten.
  • Key combinations that involve Ctrl+Alt are not permitted in order to avoid conflicts with the AltGr key.

Clearly Chrome has an interesting definition of what counts as a "letter" key to be used with modifiers (as you've discovered, . and , are fine, but other characters aren't).

msva commented 2 years ago

either Ctrl or Alt

is it mutually exclusive "either"?

gilmoreorless commented 2 years ago

is it mutually exclusive "either"?

Yes, it can't be both together. Quoting from my previous link:

Key combinations that involve Ctrl+Alt are not permitted in order to avoid conflicts with the AltGr key.

On keyboard layouts that lack a dedicated "alternate graphics" key (AltGr), the Ctrl+Alt combination is sometimes used to mimic it. From Wikipedia:

On some compact keyboards like those of netbooks, the right Alt key may be missing altogether. To allow the specific functionality of AltGr when typing non-English text on such keyboards, some OSs such as Microsoft Windows emulate the function by treating the Alt key and Control key pressed together as an AltGr key.

Therefore, Microsoft recommends that this combination not be used as a keyboard shortcut in Windows applications as, depending on the keyboard layout and configuration, someone trying to type a special character with it may accidentally trigger the application shortcut.

This will be why Chrome prevents using both modifiers together for keyboard shortcuts. It does this for all extensions, not just this one.