24

You can preventDefault() on Chrome shortcuts with JavaScript, but you can't do it with all of them.

Ctrl + S and Ctrl + F you can override.

Ctrl + W you cannot. This makes sense.

Ctrl + L though I was surprised to find you also cannot override though.

What shortcuts are overridable and which aren't in Chrome?

Slbox
  • 10,957
  • 15
  • 54
  • 106
  • 3
    https://bugs.chromium.org/p/chromium/issues/detail?id=33056 has some more information. – moltenform Mar 13 '18 at 22:59
  • 1
    Ctrl-NTW, Ctrl Tab, Ctrl Shift Tab also appear to be non-overridable. Apparently Ctrl-Q can be overridden but not Ctrl-Shift-Q. – moltenform Mar 13 '18 at 23:00
  • 2
    Ctrl+L can be overridden: the editor on this site has it as a shortcut for "insert link." I verified that it works in Chrome 88 (and also Firefox 87). – Ryan M Jan 28 '21 at 01:43
  • 3
    [Keymaster](https://github.com/madrobby/keymaster) and [Keypress](http://dmauro.github.io/Keypress/) have a lot of it figured out. Furthermore the [DOM living standard](https://dom.spec.whatwg.org/#dom-event-preventdefault) of all things just states that "There are scenarios where invoking preventDefault() has no effect. User agents are encouraged to log the precise cause in a developer console, to aid debugging." – Swiffy Jun 18 '22 at 00:25
  • is it possible to overrider chrome incognito shortcut (Ctrl Shift N) using javascript? – Sagar Shah Oct 04 '22 at 06:22

2 Answers2

0

Within Chrome, here are the non-overridable commands that I have found:

Ctrl Tab, Ctrl-NTW, Ctrl-W

Most 'Ctrl-Shift' keyboard shortcuts are able to be overridden now with a few exceptions:

Ctrl Shift Tab, Ctrl-Shift-Q

Ctrl-L is now overridable along a few other new Ctrl-Shift shortcuts.

Micah
  • 479
  • 1
  • 7
  • 17
0

These shortcuts can not be overridden because of security and user experience:

Ctrl + W
Ctrl + L
Ctrl + T
Ctrl + N
F5
Ctrl + Shift + T 
Ctrl + Tab

References:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent https://support.google.com/chrome/answer/157179

Hammad Ahmed khan
  • 1,618
  • 7
  • 19