In the JS API there is onAppEvent allowing to listen for an event. But how can I find the list of these events? I tried searching for onAppEvent and .trigger(, but have not found much.
This specific event is handled by the browser, Discourse doesn’t have its own event here. But you can have a JS listener for the prefers-color-scheme media query. See How to detect dark mode using JavaScript (or search Google for other examples).