// 获取事件需要绑定的节点
var inp = document.getElementById('id')
// 创建初始化 event 事件 var event = new KeyboardEvent("keyup", {which: 13, keyCode: 13, key: 'Enter', code: 'Enter'});
// 执行 inp.dispatchEvent(event)
参考:https://developer.mozilla.org/zh-CN/docs/Web/API/KeyboardEvent/KeyboardEvent
标签:KeyboardEvent,inp,JS,键盘,Enter,var,event,模拟 From: https://www.cnblogs.com/Perjak/p/17767209.html