Skip to content
11 changes: 11 additions & 0 deletions var/httpd/htdocs/js/Core.Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ Core.Form = (function (TargetNS) {
$("form input, select, textarea").off('change', FormModified);
}

/**
* This makes all forms submittable by using Enter inside inputs.
*/
$('body').on('keydown', 'input', function (Event) {
if (Event.keyCode == 13 && $(this).closest('form').find(':submit').length > 0) {
Event.preventDefault();
$(this.form).find(':submit').last().click();
}
});

/**
* This makes all forms submittable by using Ctrl+Enter inside textareas.
* On macOS you can use Command+Enter instead.
Expand All @@ -303,6 +313,7 @@ Core.Form = (function (TargetNS) {
if ((Event.ctrlKey || Event.metaKey) && Event.keyCode == 13) {
// We need to click() instead of submit(), since click() has
// a few useful event handlers tied to it, like validation.
Event.preventDefault();
$(this.form).find(':submit').last().click();
}
});
Expand Down
Loading