The UIEvent interface represents simple user interface events.

UIEvent derives from Event. Although the UIEvent.initUIEvent() method is kept for backward compatibility, you should create a UIEvent object using the UIEvent() constructor.

Several interfaces are direct or indirect descendants of this one: MouseEvent, TouchEventFocusEvent, KeyboardEvent, WheelEvent, InputEvent, and CompositionEvent.

Constructors

UIEvent()
Creates a UIEvent object.

Properties

This interface also inherits properties of its parent, Event.

UIEvent.cancelBubble  
Is a Boolean indicating whether the bubbling of the event has been canceled or not.
UIEvent.detailRead only
Returns a long with details about the event, depending on the event type.
UIEvent.isChar Read only
Returns a Boolean indicating whether the event produced a key character or not.
UIEvent.layerX Read only
Returns the horizontal coordinate of the event relative to the current layer.
UIEvent.layerY Read only
Returns the vertical coordinate of the event relative to the current layer.
UIEvent.pageX Read only
Returns the horizontal coordinate of the event relative to the whole document.
UIEvent.pageY Read only
Returns the vertical coordinate of the event relative to the whole document.
UIEvent.sourceCapabilities  Read only
Returns an instance of the InputDeviceCapabilities interface which provides information about the physical device responsible for generating a touch event.
UIEvent.viewRead only
Returns a WindowProxy that contains the view that generated the event.
UIEvent.which Read only  
Returns the numeric keyCode of the key pressed, or the character code (charCode) for an alphanumeric key pressed.

Methods

This interface also inherits methods of its parent, Event.

UIEvent.initUIEvent()
Initializes a UIEvent object. If the event has already being dispatched, this method does nothing.

Specifications

Specification Status Comment
InputDeviceCapabilities Draft Added sourceCapabilities property.
UI Events Working Draft Extend DOM3
Document Object Model (DOM) Level 3 Events Specification
The definition of 'UIEvent' in that specification.
Obsolete Added the UIEvent() constructor, deprecated the initUIEvent() method and changed the type of view from AbstractView to WindowProxy.
Document Object Model (DOM) Level 2 Events Specification
The definition of 'UIEvent' in that specification.
Obsolete Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes Yes Yes ? Yes ?
UIEvent() constructor Yes Yes11 ? Yes ?
cancelBubble Yes Yes Yes Yes Yes Yes
detail Yes Yes Yes9 Yes Yes
initUIEvent Yes Yes Yes ? Yes ?
isChar No No Yes — 551 No No No
layerX Yes Yes Yes9 Yes Yes
layerY Yes Yes Yes9 Yes Yes
pageX Yes — 442 ? ?9 ? ?
pageY Yes — 443 ? ?9 ? ?
sourceCapabilities47 ? ? ? ? ?
view Yes Yes Yes9 Yes Yes
which ? ? ? ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes Yes Yes ? ?
UIEvent() constructor Yes Yes Yes14 Yes ? ?
cancelBubble Yes Yes Yes Yes Yes Yes ?
detail Yes Yes Yes Yes Yes Yes ?
initUIEvent Yes Yes Yes Yes Yes ? ?
isChar No No No Yes — 551 No No No
layerX Yes Yes Yes Yes Yes Yes ?
layerY Yes Yes Yes Yes Yes Yes ?
pageX Yes — 442 Yes — 442 ? ? ? ? ?
pageY Yes — 443 Yes — 443 ? ? ? ? ?
sourceCapabilities4747 ? ? ? ? ?
view Yes Yes Yes Yes Yes Yes ?
which ? ? ? ? ? ? ?

1. The isChar property has never been supported by any browser but Firefox, and even on Firefox it's never worked except on Mac OSX. For that reason, it's been removed in Firefox 55 to align with other browsers.

2. Replaced by MouseEvent.pageX in version 45.

3. Replaced by MouseEvent.pageY in version 45.

See also

Document Tags and Contributors

Last updated by: fscholz,