Skip to content

Instantly share code, notes, and snippets.

Last active June 9, 2023 11:40
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alexkingorg/03bcc2004c0bc9145e23 to your computer and use it in GitHub Desktop.
Submit a form on Command+Enter when in a textarea field.
jQuery(function($) {
// add a handler for form submit (makes an AJAX call)
$(document).on('submit', '', myFormSubmitHandler);
// submit form on command + enter if in a textarea
$(document).on('keydown', 'body', function(e) {
if (!(e.keyCode == 13 && e.metaKey)) return;
var $target = $(;
if ($'textarea')) {
Copy link

Thank you~
I just search about that subject and finally cleared!

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