DOM:event.initKeyEvent
z Mozilla Developer Center, polskiego centrum programistów Mozilli.
UWAGA: Tłumaczenie tej strony nie zostało zakończone.
Może być ona niekompletna lub wymagać korekty.
Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron...
Spis treści |
[edytuj] Podsumowanie
The initKeyEvent method is used to initialize the value of an event created using document.createEvent ("KeyboardEvent");.
[edytuj] Składnia
event.initKeyEvent (type, bubbles, cancelable, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, keyCodeArg, charCodeArg)
type- The type of event.
bubbles- A boolean indicating whether the event should bubble up through the event chain or not (see bubbles).
cancelable- A boolean indicating whether the event can be canceled (see cancelable).
viewArg- Specifies UIEvent.view. This value may be null.
ctrlKeyArg- bool True if the Virtual Key to be generated is a combination of the Ctrl key and other keys
altKeyArg- bool True if the Virtual Key to be generated is a combination of the Alt key and other keys
shiftKeyArg- bool True if the Virtual Key to be generated is a combination of the Shift key and other keys
metaKeyArg- bool True if the Virtual Key to be generated is a combination of the Meta key and other keys
keyCodeArg- unsigned long the virtual key code value of the key which was depressed, otherwise zero
charCodeArg- unsigned long the Unicode character associated with the depressed key otherwise zero
see http://lxr.mozilla.org/mozilla/source/dom/public/idl/events/nsIDOMKeyEvent.idl for a list of key codes
[edytuj] Przykład
// create a key event
event.initKeyEvent(
"keypress", // in DOMString typeArg,
true, // in boolean canBubbleArg,
true, // in boolean cancelableArg,
null, // in nsIDOMAbstractView viewArg, Specifies UIEvent.view. This value may be null.
false, // in boolean ctrlKeyArg,
false, // in boolean altKeyArg,
false, // in boolean shiftKeyArg,
false, // in boolean metaKeyArg,
9, // in unsigned long keyCodeArg,
0); // in unsigned long charCodeArg);
[edytuj] Uwagi
Events initialized in this way must have been created with the document.createEvent("KeyboardEvent");. method. initKeyEvent must be called to set the event before it is dispatched.
[edytuj] Specyfikacja
This implementation of keyboard events is based on the key events spec in early versions of DOM 2 Events, later removed from that spec.
The initKeyEvent is the current GECKO equivalent of the Dom level 3 event draft initKeyboardEvent method with the following arguments :
typeArg of type DOMString canBubbleArg of type boolean cancelableArg of type boolean viewArg of type views::AbstractView keyIdentifierArg of type DOMString keyLocationArg of type unsigned long modifiersList of type DOMString);