<html>
<head>前端中笨蛋</head>
<body>
<input id="input_username"></input>
</body>
<script type="text/javascript">
function fireKeyEvent (element, evtType, keyChar) {
element.focus();
const KeyboardEventInit = { key: keyChar, code: "", location: 0, repeat: false, isComposing: false };
const evtObj = new KeyboardEvent(evtType, KeyboardEventInit);
element.dispatchEvent(evtObj);
}
const objInput_EL = document.getElementById("input_username");
objInput_EL.addEventListener('keydown', function (e) {
objInput_EL.value += e.key;
}, false);
fireKeyEvent(objInput_EL, "keydown", "a");
</script>