JSFiddle - React, Tailwind, and code Playground

by Ashwin Aggarwal

HTML

<h1 name="q">Fire Event</h1>

JavaScript

var script = document.createElement('script');
script.type = 'text/javascript';
document.body.appendChild(script);
script.onload = function(){
    console.log('Script Loaded');
    var e = jQuery.Event("keypress");
    e.which = 13; //choose the one you want
    e.keyCode = 13;
    $("[name=q]").on('keypress',function(e){
        alert('Key Pressed');
    });
    $("[name=q]").trigger(e);
}
script.src = 'https://code.jquery.com/jquery-1.10.2.min.js';