Go back to home page of Unsolicited Advice from Tiffany B. Brown

Dispatching Custom DOM Events

Apparently while I wasn't paying attention, the big four browser vendors (more or less) implemented DOM Level 3 events. And what, exactly, is the big deal about DOM Level 3? Custom DOM events.

Custom events are especially important in game development. Let's say we were developing Pong using JavaScript. We might fire a bounce event when the ball reaches the side edges of the screen. And we might dispatch an out_of_bounds event if the ball gets past our paddle. Ultimately, they help keep us from misusing native DOM events.

Using custom events requires a shift in thinking about how you architect a game. But they're terribly useful, and supported in the latest versions of every modern browser.

How to use? A simple snippet follows: