Web KeyboardEvent


```typevar keyboardEvent = document.createEvent('KeyboardEvent');var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';keyboardEvent[initMethod](  'keypress', // event type: keydown, keyup, keypress  true, // bubbles  true, // cancelable  window, // view: should be window  true, // ctrlKey  false, // altKey  false, // shiftKey  false, // metaKey  80, // keyCode: unsigned long - the virtual key code, else 0  0, // charCode: unsigned long - the Unicode character associated with the depressed key, else 0);document.dispatchEvent(keyboardEvent);```



```type```













[HTML keydown](https://texonom.com/html-keydown-a4a056271fff4c8690d36e1535607356)

- keyup
> - for printable
- keypress
> - for unprintable