I recently had the same problem while migrating my dropdowns from Alipine to JS commands.
I ended up removing the phx-window-keydown and in the hook, adding an event listener on keydown when key is Escape. Then event triggered the JS I had defined for phx-click-away on the dropdown panel, using this.liveSocket.execJS.
If you look at livebeats they click the document body and focus the element in the menu(?) Hook.






















