按Enter键时如何使用Jquery Mulitple Autocomplete在文本区域中添加新行?

我正在使用它但在textarea而不是输入字段

https://jqueryui.com/autocomplete/#multiple

我的JQuery代码如下

 $(function() { var availableTags = [ "Headache", "Headache all the time", "Increase in the morning", "Headache with effect on vision", "only episodic Headache with Vomiting", "one sided Headache" ]; function split( val ) { return val.split( / \s*/ ); } function extractLast( term ) { return split( term ).pop(); } $( ".tags" ) // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); } }) .autocomplete({ minLength: 0, source: function( request, response ) { // delegate back to autocomplete, but extract the last term response( $.ui.autocomplete.filter( availableTags, extractLast( request.term ) ) ); }, focus: function() { // prevent value inserted on focus return false; }, select: function( event, ui ) { var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end terms.push( "" ); this.value = terms.join( " " ); return false; } }); });  

目前textarea正在显示http://prntscr.com/7cxvgb ,我想要的是http://prntscr.com/7cxvvd意味着每当我按下输入文本区域时它应该添加新行。

当前输出http://prntscr.com/7cxweu但是当我在textarea中输入时我想要这个新行。 提前致谢。