KeyboardEvent()
构造函数创建新
KeyboardEvent
.
event = new KeyboardEvent(typeArg, KeyboardEventInit);
DOMString
表示事件的名称。
KeyboardEventInit
字典,拥有以下字段:
"key"
, optional and defaulting to
""
, of type
DOMString
, that sets the value of
KeyboardEvent.key
.
"code"
, optional and defaulting to
""
, of type
DOMString
, that sets the value of
KeyboardEvent.code
.
"location"
, optional and defaulting to
0
, of type
unsigned long
, that sets the value of
KeyboardEvent.location
.
"ctrlKey"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.ctrlKey
.
"shiftKey"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.shiftKey
.
"altKey"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.altKey
.
"metaKey"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.metaKey
.
"repeat"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.repeat
.
"isComposing"
, optional and defaulting to
false
, of type
布尔
, that sets the value of
KeyboardEvent.isComposing
.
"charCode"
, optional and defaulting to
0
, of type
unsigned long
, that sets the value of the deprecated
KeyboardEvent.charCode
.
"keyCode"
, optional and defaulting to
0
, of type
unsigned long
, that sets the value of the deprecated
KeyboardEvent.keyCode
.
"which"
, optional and defaulting to
0
, of type
unsigned long
, that sets the value of the deprecated
KeyboardEvent.which
.
KeyboardEventInit
字典还接受字段来自
UIEventInit
and
EventInit
字典。
| 规范 | 状态 | 注释 |
|---|---|---|
|
UI Events
The definition of 'KeyboardEvent()' in that specification. |
工作草案 | Current definition. |
|
DOM (文档对象模型) 3 级事件规范
The definition of 'KeyboardEvent()' in that specification. |
过时 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
KeyboardEvent()
构造函数
|
Chrome Yes | Edge ≤79 | Firefox 31 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 31 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
添加
code
and
key
to
KeyboardEventInit
|
Chrome 49 | Edge ≤79 | Firefox ? | IE No | Opera ? | Safari ? | WebView Android 49 | Chrome Android 49 | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android 5.0 |
完整支持
不支持
兼容性未知
KeyboardEvent
,构造对象的接口。
KeyboardEvent
KeyboardEvent()