Skip to content

Instantly share code, notes, and snippets.

@joelrbrandt
Last active April 2, 2020 21:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joelrbrandt/db09a4360782d88636c318a089bb5c29 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Trap ctrl+enter on git.corp
// @description Stop git.corp from handling ctrl+enter keyboard shortcut (e.g., for submitting issue comment)
// @run-at document-start
// @version 0.1
// @author Joel Brandt <jobrandt@adobe.com>
// @match https://git.corp.adobe.com/*
// @grant none
// @downloadURL https://gist.githubusercontent.com/joelrbrandt/db09a4360782d88636c318a089bb5c29/raw/trap-ctrl-enter.js
// @updateURL https://gist.githubusercontent.com/joelrbrandt/db09a4360782d88636c318a089bb5c29/raw/trap-ctrl-enter.js
// ==/UserScript==
const ENTER_KEYCODE = 13;
// multi-browser keydown event binding/cancellation documented here:
// https://stackoverflow.com/questions/19785368/greasemonkey-script-to-intercept-key-presses
(window.opera ? document.body : document).addEventListener("keydown", function (e) {
if (e.keyCode === ENTER_KEYCODE && e.ctrlKey) {
e.cancelBubble = true;
e.stopImmediatePropagation();
}
return false;
}, !window.opera);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment