Creating an Arrow Event for DOM Subscription

This example will illustrate how to use the synthetic event creation API. We'll create an arrow event that fires in response to the user pressing the arrow keys (up, down, left, right) and adds a direction property to the generated event.

Subscribing to this new event will look like this:

  1. node.on("arrow", onArrowHandler);
  2.  
node.on("arrow", onArrowHandler);
 

Support will also be added for delegation, allowing a single subscriber from a node higher up the DOM tree, to listen for the new event emanating from its descendant elements.

  1. containerNode.delegate("arrow", onArrowHandler, ".robot");
  2.  
containerNode.delegate("arrow", onArrowHandler, ".robot");
 

Step 1. to the arrow event.

Step 2. Click on a robot and move it around with the arrow keys.