Skip to content

Instantly share code, notes, and snippets.

@samsondav
Last active January 22, 2024 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsondav/e6a0a7740cdf955a88b590e781d96b62 to your computer and use it in GitHub Desktop.
Save samsondav/e6a0a7740cdf955a88b590e781d96b62 to your computer and use it in GitHub Desktop.
Disable cmd+enter send in gmail
// ==UserScript==
// @name Gmail disable cmd+enter
// @namespace sampdavies@gmail.com
// @description Disables cmd+enter from sending an email in gmail
// @include ^https?:\/\/mail\.google\.com.*$
// @version 1
// @grant none
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.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 = isMac ? e.metaKey : 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();
return;
}
// s'more mac love
if (!isMac) {
return;
}
}, true);
})();
@wamatt
Copy link

wamatt commented Oct 14, 2016

This is awesome!

@ciarpame
Copy link

Great idea, I tried today on both Firefox (using Greasemonkey) and Chrome (Tampermonkey) but it does not work for me, Ctrl-Enter still works and the message is sent (anyway I still can stop it with the Undo option).
It's just me?

@PatrickvEk
Copy link

For me this didn't work anymore.

I created an updated version here:
https://gist.github.com/PatrickvEk/c942b0e2bb0b9f9d34b33820aab07ec5#file-disable-gmail-cmd-enter-2024-user-js

I hope it works for everyone that finds this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment