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
Menu