How to simulate both keydown and keyup events in Js?

I now need to port a Mini Game written in Js for the PC platform to the mobile platform, so I want to use a method called pressKey to simulate sending a keystroke event. PressKey includes two operations, pressKeyDown and pressKeyUp, but pressKey is invalid when I don"t use setTimeout to wrap pressKeyUp as a macro task. So I would like to ask what is the relationship between a specific event and a micro task or macro task? For example, will it appear in event-table when a click event is generated? If so, is he a micro task?

reference: https://juejin.im/post/59e85e.

Jan.21,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e10d-2b127.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e10d-2b127.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?