0

The goal is to override Cmd+Shift+[ in Chrome.

This question is similar and was considered already, but unfortunately does not help. Cmd+Shift+[ is not a prohibited combination, so it's unclear why it can't be overridden.

The code below overrides Cmd+[, but fails to override Cmd+Shift+[. Instead, the browser default for Chrome occurs instead.

How to override both Cmd+[ and Cmd+Shift+[?

Codepen: https://codepen.io/anon/pen/pXbBZr?editors=1111

function initKeyboardEvents() {
   $(document).keydown(function(event) {

      // Ctrl/Cmd+Shift+[? Move to back.
      if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.keyCode == 219) {
         // Stop browser default.
         event.preventDefault();

         // Push to back.
         alert("push to back");
      }

      // Ctrl/Cmd+[? Move back one layer.
      if ((event.ctrlKey || event.metaKey) && event.keyCode == 219) {
         // Stop browser default.
         event.preventDefault();

         // Push back.
         alert("push back one layer");
      }
   });
}


$(document).ready(function() {
  initKeyboardEvents();

  console.log("document ready");
 });
Crashalot
  • 33,605
  • 61
  • 269
  • 439
  • 1
    Possible duplicate of [Overriding shortcut keys in firefox and chrome](https://stackoverflow.com/questions/15911785/overriding-shortcut-keys-in-firefox-and-chrome) – Tim VN Jun 18 '19 at 10:37
  • 1
    Heh, I can't actually find what that [shortcut does](https://developers.google.com/web/tools/chrome-devtools/shortcuts). – Lewis Jun 18 '19 at 10:37
  • @Lewis if you have multiple tabs open, it opens another tab – Crashalot Jun 18 '19 at 19:14
  • @TimVN the question is similar and was considered already, but unfortunately does not help. Cmd+Shift+[ is not a prohibited combination, so it's unclear why it can't be overridden. – Crashalot Jun 18 '19 at 19:17
  • That’s cmd+t. Have you confirmed that it’s not a shortcut within MacOS? – Lewis Jun 18 '19 at 19:32
  • @Lewis Cmd+t opens a new tab. If you have multiple tabs *already* open, try doing `Cmd+Shift+[` – Crashalot Jun 18 '19 at 20:15
  • @Crashalot any solution I'm also facing same issue – Vinod Louis Feb 04 '21 at 13:25

0 Answers0