The paste event is fired when the user has initiated a "paste" action through the browser's user interface.
If the cursor is in an editable context (for example, in a <textarea> or an element with contenteditable attribute set to true) then the default action is to insert the contents of the clipboard into the document at the cursor position.
A handler for this event can access the clipboard contents by calling getData() on the event's clipboardData property.
To override the default behavior (for example to insert some different data or a transformation of the clipboard contents) an event handler must cancel the default action using event.preventDefault(), and then insert its desired data manually.
It's possible to construct and dispatch a synthetic paste event, but this will not affect the document's contents.