files/en-us/web/api/keyboardevent/initkeyboardevent/index.md
{{APIRef("UI Events")}}{{Deprecated_Header}}
The KeyboardEvent.initKeyboardEvent() method initializes
the attributes of a keyboard event object. This method was introduced in draft of DOM
Level 3 Events, but deprecated in newer draft. Gecko won't support this feature since
implementing this method as experimental broke existing web apps (see Firefox bug 999645).
Web applications should use constructor instead of this if it's available.
initKeyboardEvent(type, canBubble, cancelable,
view, key, location, ctrlKey,
altKey, shiftKey, metaKey)
type
keydown,
keypress, or keyup.canBubble {{optional_inline}}
false.cancelable {{optional_inline}}
false.view {{optional_inline}}
null.key {{optional_inline}}
"".location {{optional_inline}}
0.ctrlKey {{optional_inline}}
false.altKey {{optional_inline}}
false.shiftKey {{optional_inline}}
false.metaKey {{optional_inline}}
false.None ({{jsxref("undefined")}}).
{{Specifications}}
The KeyboardEvent interface specification went through numerous draft versions, first under DOM Events Level 2 where it was dropped as no consensus arose, then under DOM Events Level 3. This led to the implementation of non-standard initialization methods, the early DOM Events Level 2 version, KeyboardEvent.initKeyEvent() by Gecko browsers and the early DOM Events Level 3 version, KeyboardEvent.initKeyboardEvent() by others. Both have been superseded by the modern usage of a constructor: {{domxref("KeyboardEvent.KeyboardEvent", "KeyboardEvent()")}}.
{{Compat}}