User:Gary.johnson.53

There was a scripting error on this page. While it is being addressed by site editors, you can view partial content below.

{{ DomRef }}

Summary

The initKeyEvent method is used to initialize the value of an event created using document.createEvent ("KeyboardEvent");.

Syntax

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
altKeyArg 
bool
shiftKeyArg 
bool
metaKeyArg 
bool
keyCodeArg 
unsigned long
charCodeArg
unsigned long

Example

// 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,                                                       
                   0,               //  in unsigned long keyCodeArg,                                                      
                   9);              //  in unsigned long charCodeArg);              

Notes

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.

Specification

This implementation of keyboard events is based on the key events spec in early versions of DOM 2 Events, later removed from that spec. -David Baron 09:34, 23 September 2006 (PDT)

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);

Document Tags and Contributors

Contributors to this page: Gary.johnson.53
Last updated by: Gary.johnson.53,