Skip to content

Instantly share code, notes, and snippets.

@PatrickvEk
Last active January 22, 2024 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickvEk/c942b0e2bb0b9f9d34b33820aab07ec5 to your computer and use it in GitHub Desktop.
Save PatrickvEk/c942b0e2bb0b9f9d34b33820aab07ec5 to your computer and use it in GitHub Desktop.
Gmail Disable accidental sending Ctrl+Enter
// ==UserScript==
// @name Gmail Disable accidental sending
// @namespace http://tampermonkey.net/
// @version 2024-01-22
// @description Disable Ctrl+Enter to send, in order to prevent accidental sending
// @author Patrick van Ek
// @match https://mail.google.com/mail/*
// @icon https://mail.google.com/favicon.ico
// @grant none
// ==/UserScript==
// INSTALL TAMPERMONKEY IN YOUR BROWSER TO USE THIS SCRIPT
(function(){
window.document.addEventListener('keydown', function(e) {
// Mac uses the Command key, identified as metaKey
// Windows and Linux use the Control key, identified as ctrlKey
var modifier = e.ctrlKey;
// abort if the proper command/control modifier isn't pressed
if (!modifier) {
return;
}
switch (e.keyCode) {
case 13: // Enter - (disable cmd-enter to send in gmail)
e.stopImmediatePropagation();
console.log("Prevented accidental send");
return;
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment