Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

wamatt commented Oct 14, 2016

This is awesome!

@ciarpame

This comment has been minimized.

Copy link

ciarpame commented Oct 31, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.