I also have similar JS_LISTENER_KEYEVENT code running, but have never tried to make it work with custom events.
I believe that Matt and Dominic at WT, were responsible for the introduction of JS_LISTENER_KEYEVENT into MSFS sometime in mid 2021.
Maybe try asking Matt directly on the WT Discord .
I have always found him most helpful, and willing to share technical information w.r.t. MSFS & JS