Properties Methods Events Direct Link

# Class Ext.EventObject

Package: | Ext
Defined In: | EventManager.js
Class: | EventObject
Extends: | Object

EventObject exposes the Yahoo! UI Event functionality directly on the object passed to your event handler. It exists mostly for convenience. It also fixes the annoying null checks automatically to cleanup your code Example:

    function handleClick(e){ // e is not a standard event object, it is a Ext.EventObject
        e.preventDefault();
        var target = e.getTarget();
        ...
     }
     var myDiv = Ext.get("myDiv");
     myDiv.on("click", handleClick);
     //or
     Ext.EventManager.on("myDiv", 'click', handleClick);
     Ext.EventManager.addListener("myDiv", 'click', handleClick);

This class is a singleton and cannot be created directly.

## Public Properties

Property | Defined By
--- | ---
| BACKSPACE : Number Key constant | EventObject
| CONTROL : Number Key constant | EventObject
| DELETE : Number Key constant | EventObject
| DOWN : Number Key constant | EventObject
| END : Number Key constant | EventObject
| ENTER : Number Key constant | EventObject
| ESC : Number Key constant | EventObject
| F5 : Number Key constant | EventObject
| HOME : Number Key constant | EventObject
| LEFT : Number Key constant | EventObject
| PAGEDOWN : Number Key constant | EventObject
| PAGEUP : Number Key constant | EventObject
| RETURN : Number Key constant | EventObject
| RIGHT : Number Key constant | EventObject
| SHIFT : Number Key constant | EventObject
| SPACE : Number Key constant | EventObject
| TAB : Number Key constant | EventObject
| UP : Number Key constant | EventObject
| altKey : Object True if the alt key was down during the event | EventObject
| browserEvent : Object The normal browser event | EventObject
| button : Object The button pressed in a mouse event | EventObject
| ctrlKey : Object True if the control key was down during the event | EventObject
| shiftKey : Object True if the shift key was down during the event | EventObject

## Public Methods

Method | Defined By
--- | ---
| getCharCode() : Number Gets the key code for the event. Gets the key code for the event. Parameters: None. Returns: `Number` | EventObject
| getKey() : Number Returns a normalized keyCode for the event. Returns a normalized keyCode for the event. Parameters: None. Returns: `Number` The key code | EventObject
| getPageX() : Number Gets the x coordinate of the event. Gets the x coordinate of the event. Parameters: None. Returns: `Number` | EventObject
| getPageY() : Number Gets the y coordinate of the event. Gets the y coordinate of the event. Parameters: None. Returns: `Number` | EventObject
| getRelatedTarget() : HTMLElement Gets the related target. Gets the related target. Parameters: None. Returns: `HTMLElement` | EventObject
| getTarget( [`String selector`], [`Number/Mixed maxDepth`], [`Boolean returnEl`] ) : HTMLelement Gets the target for the event. Gets the target for the event. Parameters: `selector` : String (optional) A simple selector to filter the target or look for an ancestor of the target `maxDepth` : Number/Mixed (optional) The max depth to search as a number or element (defaults to 10 || document.body) `returnEl` : Boolean (optional) True to return a Ext.Element object instead of DOM node Returns: `HTMLelement` | EventObject
| getTime() : Number Gets the time of the event. Gets the time of the event. Parameters: None. Returns: `Number` | EventObject
| getWheelDelta() : Number Normalizes mouse wheel delta across browsers Normalizes mouse wheel delta across browsers Parameters: None. Returns: `Number` The delta | EventObject
| getXY() : Array Gets the page coordinates of the event. Gets the page coordinates of the event. Parameters: None. Returns: `Array` The xy values like [x, y] | EventObject
| hasModifier() : Boolean Returns true if the control, meta, shift or alt key was pressed during this event. Returns true if the control, meta, shift or alt key was pressed during this event. Parameters: None. Returns: `Boolean` | EventObject
| preventDefault() : void Prevents the browsers default handling of the event. Prevents the browsers default handling of the event. Parameters: None. Returns: `void` | EventObject
| stopEvent() : void Stop the event (preventDefault and stopPropagation) Stop the event (preventDefault and stopPropagation) Parameters: None. Returns: `void` | EventObject
| stopPropagation() : void Cancels bubbling of the event. Cancels bubbling of the event. Parameters: None. Returns: `void` | EventObject
| within( `Mixed el`, [`Boolean related`] ) : Boolean Returns true if the target of this event equals el or is a child of el Returns true if the target of this event equals el or is a child of el Parameters: `el` : Mixed `related` : Boolean (optional) true to test if the related target is within el instead of the target Returns: `Boolean` | EventObject

## Public Events

This class has no public events.