Besides the standard HTML events that you saw earlier in this chapter, you can also create custom events of your own. For example, you may want to create a custom event for a user pressing the Caps Lock key; you can do this by adding (extending) properties to the Element.Events
object in MooTools. Here is the format for adding event properties to the Element.Events
MooTools object:
Element.Events.eventname = { 'base' : 'click', // A base event such as click, keypress, keydown, onload, etc. 'condition' : function() { // conditions that need to be met to trigger event }, 'onAdd' : function() { // Functions to trigger when you bind/add the event to elements }, 'onRemove' : function() { // Functions to execute when you unbind/remove elements } };
There are five things to take a note off in the above code sample.
eventname:
This is the name of your custom event.base:
This is an optional string value which gives our custom event a standard event to listen to. If you have...