JS, jQuery on input ENTER keypress submit form

$('.input').on('keypress', function (e) {
        if (e.key !== 'Enter') {
            return;
        }
        $(this).closest('form').submit();
    });