Last active
August 29, 2015 14:05
-
-
Save bi0xid/6e8b1ac0f086cd416303 to your computer and use it in GitHub Desktop.
Send form using ctrl+enter / cmd+enter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function () { | |
document.getElementById("commentform").onkeydown = function (e) { | |
if (e.keyCode == 13 && e.ctrlKey) { // keyCode 13 is Enter | |
document.getElementById("submit").click(); // submit the form by hitting ctrl + enter | |
// alert(e.keyCode); // to know other keyCodes of each keys | |
return false; // preventing default action | |
} | |
if (e.keyCode == 13 && e.metaKey) { // keyCode 13 is Enter | |
document.getElementById("submit").click(); // submit the form by hitting cmd + enter | |
// alert('test'); // to know other keyCodes of each keys | |
return false; // preventing default action | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment