--- title: UIEvent slug: Web/API/UIEvent tags: - API - DOM - Event - Reference - UIEvent translation_of: Web/API/UIEvent ---
{{APIRef("DOM Events")}}
UIEvent
接口表示简单的用户界面事件。
UIEvent
是从 {{domxref("Event")}} 派生出来的。尽管 {{domxref("UIEvent.initUIEvent()")}} 方法为了向后兼容而一直保留着,但是你应该使用 {{domxref("UIEvent.UIEvent", "UIEvent()")}} 构造器来创建 UIEvent
对象。
某些接口是这个的直接或间接后代:{{domxref("MouseEvent")}}, {{domxref("TouchEvent")}}, {{domxref("FocusEvent")}}, {{domxref("KeyboardEvent")}}, {{domxref("WheelEvent")}}, {{domxref("InputEvent")}}, 和{{domxref("CompositionEvent")}}.
UIEvent
对象也继承了父代 {{domxref("Event")}} 的一些属性。
long
with details about the event, depending on the event type.keyCode
,或者一个字母数字键按下时的字符码(charCode
)。也继承了父代 {{domxref("Event")}} 的一些方法。
UIEvent
对象。如果事件已经被分派,这个方法什么都不做。Specification | Status | Comment |
---|---|---|
{{SpecName('InputDeviceCapabilities')}} | {{Spec2('InputDeviceCapabilities')}} | Added sourceCapabilities property. |
{{SpecName('DOM3 Events', '#interface-UIEvent', 'UIEvent')}} | {{Spec2('DOM3 Events')}} | Added the UIEvent() constructor, deprecated the initUIEvent() method and changed the type of view from AbstractView to WindowProxy . |
{{SpecName('DOM2 Events', '#Events-UIEvent', 'UIEvent')}} | {{Spec2('DOM2 Events')}} | Initial definition |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}}[2] | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
UIEvent() |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(11)}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
cancelBubble defined on Event |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(53)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}}[2] | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
UIEvent() |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(11)}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
cancelBubble defined on Event |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(53)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] From Firefox 52, this property is now defined on the {{domxref("Event")}} interface instead. See {{bug(1298970)}} for more details.
[2] The {{domxref("UIEvent.isChar", "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.