How to manually trigger a paste event in a text area with specific text
<p>I'm trying to trigger a paste event in a <code>textarea</code> with jQuery, but this subject is quite new to me.</p>

<p>I've seen how one can manually trigger a keydown event simulating pressing a specific key like this:</p>

<pre><code>var e = $.Event("keydown")
e.which = 50
$('#textarea1').trigger(e)
</code></pre>

<p>But how can I manually trigger a paste event with a provided string of text that effectively simulates a Ctrl+V or right-click > paste of a string like "Foobar"?</p>

<p>I have tried to simply set the value of textarea but this does not trigger a paste event.</p>

<p>EDIT:</p>

<p>I have also tried this (to simulate Ctrl+V) but no luck (<a href="https://stackoverflow.com/questions/3893397/how-to-trigger-key-combo-with-jquery">ref</a>):</p>

<pre><code>e = $.Event("keydown");        
e.which = 86; // 'V' key
e.ctrlKey = true;
$("input").trigger(e);
</code></pre>