Last active
September 18, 2017 22:13
-
-
Save stevenharman/6054478 to your computer and use it in GitHub Desktop.
⌘-ENTER: submit that form!
This file contains hidden or 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
$(document).on('keydown', 'form :input:not(:disabled)', function(e) { | |
if(e.keyCode == 13 && (e.metaKey || e.ctrlKey)) { | |
$form = $(this).parents('form') | |
if ($form[0].checkValidity()) { | |
$form.submit(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jasonkarns Yes, ENTER in non-
textarea
will work. This makes for a consistent experience no matter what kind of field you're in.