Last Updated: February 25, 2016
·
1.249K
· stevenharman

⌘-ENTER to submit forms.

Make the Internet better, submit forms with ⌘-ENTER.

https://gist.github.com/stevenharman/6054478

3 Responses
Add your response

That is already the default browser behavior. Ctrl+Enter for Windows/Linux and ⌘+Enter for Mac. There is one requisite: You have to put the form fields in a <form> tag for that to work.

http://plnkr.co/edit/LxhESk?p=preview

over 1 year ago ·

Hi @twolfosn,

For your example, ⌘+Enter does nothing for me on my Mac, using latest Chrome. CTRL-Enter, does seem to submit the form. Do you have any links to spec or docs that show this to be the default behavior across browsers?

Also, the solution I presented above handles the case of textarea and select elements - does the default behavior you mentioned handle those?

over 1 year ago ·

Ah, I must have been mistaken then. I am glad to hear Ctrl+Enter still works for form submission.

Unfortunately, a quick Google search does not turn up any results. It seems to be something I have picked up over the years.

The solution above should be applicable to any elements inside of a form (e.g. textarea, select, input[type=*]).

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside