CompositionEvent

DOM 接口 CompositionEvent 表示用户间接输入文本(如使用输入法)时发生的事件。此接口的常用事件有compositionstart, compositionupdate 和 compositionend

构造函数

CompositionEvent()
创建一个新的 CompositionEvent 对象实例。

属性

这个接口也从UIEventEvent 继承属性。

CompositionEvent.data 只读
返回触发事件的输入方法所产生的字符;取决于生成 CompositionEvent 对象的事件类型,结果会有所不同。
CompositionEvent.locale 只读
返回当前输入方法的场景(例如,使用输入法编辑器进行输入合成时,场景就是键盘布局)。

方法

这个接口也从 UIEventEvent 继承方法。

CompositionEvent.initCompositionEvent()
初始化 CompositionEvent 对象的所有属性。

规范

规范 状态 注释
UI Events
CompositionEvent
Working Draft
Document Object Model (DOM) Level 3 Events Specification
CompositionEvent
Obsolete

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
CompositionEventChrome Full support YesEdge Full support 12Firefox Full support 9IE Full support YesOpera No support NoSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 9Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
CompositionEvent() constructorChrome Full support YesEdge Full support 12Firefox Full support 53IE Full support YesOpera No support NoSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 53Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
dataChrome Full support YesEdge Full support 12Firefox Full support 9IE Full support YesOpera No support NoSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 9Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
initCompositionEvent
DeprecatedNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support 9IE Full support YesOpera No support NoSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 9Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
locale
DeprecatedNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support 9IE Full support YesOpera No support NoSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 9Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

参见