KeyboardEvent()

KeyboardEvent() constructor 能用來建立一個新的 KeyboardEvent

語法

 event = new KeyboardEvent(typeArg, KeyboardEventInit);

參數

typeArg
DOMString 用來表示事件名稱。
KeyboardEventInit選擇性
一個 KeyboardEventInit dictionary,能接受以下參數:
參數 可選 默認值 類型 說明
"key" "" DOMString 用來設定 KeyboardEvent.key 的值
"code" "" DOMString 用來設定 KeyboardEvent.code 的值
"location" 0 unsigned long 用來設定 KeyboardEvent.location 的值
"ctrlKey" false Boolean 用來設定 KeyboardEvent.ctrlKey 的值
"shiftKey" false Boolean 用來設定 KeyboardEvent.shiftKey 的值
"altKey" false Boolean 用來設定 KeyboardEvent.altKey 的值
"metaKey" false Boolean 用來設定 KeyboardEvent.metaKey 的值
"repeat" false Boolean 用來設定 KeyboardEvent.repeat 的值
"isComposing" false Boolean 用來設定 KeyboardEvent.isComposing 的值
"charCode" 0 unsigned long 用來設定 KeyboardEvent.charCode 的值
"keyCode" 0 unsigned long 用來設定 KeyboardEvent.keyCode 的值
"which" 0 unsigned long 用來設定 KeyboardEvent.which 的值

 KeyboardEventInit dictionary 亦接受 UIEventInitEventInit 所接受的參數。

規格

Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
The definition of 'KeyboardEvent()' in that specification.
Working Draft Initial definition.

瀏覽器支援度

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 13 (13) Not supported (Yes) ?
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? (Yes) 31.0 (31) Not supported (Yes) ? (Yes)

延伸閱讀

  • KeyboardEvent ,此 constructer 所建立的 object 的 interface

文件標籤與貢獻者

 此頁面的貢獻者: Shiyou
 最近更新: Shiyou,