JSFiddle - React, Tailwind, and code Playground
by mcgrailm
HTML
<input type="text" id="test" />
JavaScript
$('body').append('<input type="button" id="mybutton" value="Add To Queue" /><input type="button" id="mybutton2" value="Remove From Queue" />');
var input_box = $('#test');
//var input_box = $('#div.chat-container form');
e = jQuery.Event("keypress")
e.which = 13 //choose the one you want
$('#mybutton').click(function(){
input_box.val('/marvin q'); //set the text in input box
input_box.keypress(function(){
alert('keypress triggered')
}).trigger(e) //submit by simulating keypress
});
$('#mybutton2').click(function(){
input_box.val('/marvin pq'); //set the text in input box
input_box.keypress(function(){
alert('keypress triggered')
}).trigger(e) //submit by simulating keypress
});