Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

initKeyboardEvent method

Initializes a new keyboard event that the createEvent method created.

Important  As of Microsoft Edge, the createEvent()/initEvent() constructor pattern for synthetic events is deprecated. See the Synthetic Events page for more information.
Document Object Model (DOM) Level 3 Events Specification, Section 5.2.6Internet Explorer 9

 

Syntax

var retval = KeyboardEvent.initKeyboardEvent(eventType, canBubble, cancelable, viewArg, keyArg, locationArg, modifiersListArg, repeat, locale);

Parameters

eventType [in]

Type: String

One of the following values, or a user-defined custom event type.

keydown

An onkeydown event.

keypress

An onkeypress event.

keyup

An onkeyup event.

canBubble [in]

Type: Boolean

true (true)

The event should propagate upward.

false (false)

The event does not propagate upward.

cancelable [in]

Type: Boolean

true (true)

The default action can be canceled.

false (false)

The default action cannot be canceled.

viewArg [in]

Type: IHTMLWindow2

The active window object or null. This value is returned in the view property of the event.
keyArg [in]

Type: String

The key identifier. This value is returned in the key property of the event.

locationArg [in]

Type: unsigned long

The location of the key on the device. This value is returned in the location property of the event.

modifiersListArg [in]

Type: String

A space-separated list of any of the following values:

Alt

The left or right Alt key is pressed.

AltGraph

The Ctrl and Alt keys are pressed.

CapsLock

The Caps Lock toggle is enabled.

Control

The left or right Ctrl key is pressed.

Meta

The Meta/Control key is pressed.

NumLock

The Num Lock toggle is enabled.

Scroll

The Scroll Lock toggle is enabled.

Shift

The left or right Shift key is pressed.

Win

The left or right Windows logo key is pressed.

repeat [in]

Type: Boolean

Indicates whether the event should repeat.

locale [in]

Type: String

The locale name. This value is returned in the locale attribute of the event.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

See also

KeyboardEvent

 

 

Show:
© 2015 Microsoft