The goog.events.BrowserEvent Class

goog.events.BrowserEvent
> goog.events.Event

goog.events.BrowserEvent(opt_e, opt_currentTarget)

Accepts a browser event object and creates a patched, cross browser event object. The content of this object will not be initialized if no event object is provided. If this is the case, init() needs to be invoked separately.

opt_e {Event=}
Browser event object.
opt_currentTarget {Node=}
Current target for event.

.IEButtonMap {Array.<number>}

Static data for mapping mouse buttons.

The goog.events.BrowserEvent.MouseButton Enum

Normalized button constants for the mouse. … more

.altKey {boolean}

Whether alt was pressed at time of event.

.button {number}

Which mouse button was pressed.

.charCode {number}

Keycode of key press.

.clientX {number}

X-coordinate relative to the window.

.clientY {number}

Y-coordinate relative to the window.

.ctrlKey {boolean}

Whether control was pressed at time of event.

.currentTarget {Node|undefined}

Node that had the listener attached.

.defaultPrevented {boolean}

Inherited from goog.events.Event .

Whether the default action has been prevented. This is a property to match the W3C specification at {@link http://www.w3.org/TR/DOM-Level-3-Events/#events-event-type-defaultPrevented}. Must be treated as read-only outside the class.

.getBrowserEvent()

returns {Event}
The underlying browser event object.

.init(e, opt_currentTarget)

Accepts a browser event object and creates a patched, cross browser event object.

e {Event}
Browser event object.
opt_currentTarget {Node=}
Current target for event.

.isButton(button)

Tests to see which button was pressed during the event. This is really only useful in IE and Gecko browsers. And in IE, it's only useful for mousedown/mouseup events, because click only fires for the left mouse button. Safari 2 only reports the left button being clicked, and uses the value '1' instead of 0. Opera only reports a mousedown event for the middle button, and no mouse events for the right button. Opera has default behavior for left and middle click that can only be overridden via a configuration setting. There's a nice table of this mess at http://www.unixpapa.com/js/mouse.html.

button {goog.events.BrowserEvent.MouseButton}
The button to test for.
returns {boolean}
True if button was pressed.

.isMouseActionButton()

Whether this has an "action"-producing mouse button. By definition, this includes left-click on windows/linux, and left-click without the ctrl key on Macs.

returns {boolean}
The result.

.keyCode {number}

Keycode of key press.

.metaKey {boolean}

Whether the meta key was pressed at time of event.

.offsetX {number}

X-coordinate relative to target.

.offsetY {number}

Y-coordinate relative to target.

.platformModifierKey {boolean}

Whether the default platform modifier key was pressed at time of event. (This is control for all platforms except Mac, where it's Meta.

.preventDefault()

Prevents the default action, for example a link redirecting to a url.

.propagationStopped_ {boolean}

Inherited from goog.events.Event .

Whether to cancel the event in internal capture/bubble processing for IE.

@suppress
{underscore} Technically public, but referencing this outside this package is strongly discouraged.

.relatedTarget {Node}

For mouseover and mouseout events, the related object for the event.

.returnValue_ {boolean}

Inherited from goog.events.Event .

Return value for in internal capture/bubble processing for IE.

@suppress
{underscore} Technically public, but referencing this outside this package is strongly discouraged.

.screenX {number}

X-coordinate relative to the monitor.

.screenY {number}

Y-coordinate relative to the monitor.

.shiftKey {boolean}

Whether shift was pressed at time of event.

.state {Object}

History state object, only set for PopState events where it's a copy of the state object provided to pushState or replaceState.

.stopPropagation()

Stops event propagation.

.target {Node}

Target that fired the event.