键盘事件 KeyboardEvent()

KeyboardEvent() 构造函数新建一个 KeyboardEvent 实例。

语法

 event = new KeyboardEvent(typeArg, KeyboardEventInit);

typeArg
DOMString 类型,表示事件名称。
KeyboardEventInit可选
KeyboardEventInit 字典,有以下几种值:

KeyboardEventInit 字典也可以接受来自 UIEventInitEventInit 的字典字段值。

标准

Specification Status Comment
UI Events
KeyboardEvent()
Working Draft Current definition.
Document Object Model (DOM) Level 3 Events Specification
KeyboardEvent()
Obsolete Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

特性 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本支持 (Yes) 31 (31) 未实现 (Yes) ?
初始化 code 和 key 49.0        
特性 Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
基本支持 ? (Yes) 31.0 (31) 未实现 (Yes) ? (Yes)
初始化 code 和 key 未实现 49.0         49.0

参考