Send forms using Ctrl + Enter
Many times, after I finish writting my comment or post, I press Ctrl + Enter
and ... nothing. That's too bad, form should be sent after I press that shortcut but nothing happens. Here's a snippet which will help you add this function for your forms:
var isCtrl = false;
$('textarea, input').keyup(function(e) {
if (e.which == 17) isCtrl = false;
}).keydown(function(e) {
if (e.which == 17) isCtrl = true;
if (e.which == 13 && isCtrl === true) {
$(this).closest('form').submit();
return false;
}
});
Orginal post on my blog
Upvote on HN coz I want to see this function on much more websites :)
Written by Kasper Mikiewicz
Related protips
1 Response
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/33083/98aba6d508f3f1e7fd6b21e8bfdb6b6c.png)
I wish this was mandatory for all websites. (as I write this I notice that Coderwall doesn't have it.)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Snippet
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#