Report an issue
Class

CKEDITOR.dom.event

class

Represents a native DOM event object.

Filtering

Properties

  • readonly

    $ : Object

    The native DOM event object represented by this class instance.

Methods

  • constructor( domEvent ) → event

    Creates an event class instance.

    Parameters

    domEvent : Object

    A native DOM event object.

    Returns

    event
  • getKey() → Number

    Gets the key code associated to the event.

    alert( event.getKey() ); // '65' if 'a' has been pressed
    

    Returns

    Number

    The key code.

  • getKeystroke() → Number

    Gets a number represeting the combination of the keys pressed during the event. It is the sum with the current key code and the CKEDITOR.CTRL, CKEDITOR.SHIFT and CKEDITOR.ALT constants.

    alert( event.getKeystroke() == 65 );                                    // 'a' key
    alert( event.getKeystroke() == CKEDITOR.CTRL + 65 );                    // CTRL + 'a' key
    alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 );   // CTRL + SHIFT + 'a' key
    

    Returns

    Number

    The number representing the keys combination.

  • getPageOffset() → Object

    Retrieves the coordinates of the mouse pointer relative to the top-left corner of the document, in mouse related event.

    element.on( 'mousemouse', function( ev ) {
        var pageOffset = ev.data.getPageOffset();
        alert( pageOffset.x );          // page offset X
        alert( pageOffset.y );          // page offset Y
    } );
    

    Returns

    Object

    The object contains the position.

    Properties
    x : Number
    y : Number
  • getPhase() → Number

    Returns an integer value that indicates the current processing phase of an event. For browsers that doesn't support event phase, CKEDITOR.EVENT_PHASE_AT_TARGET is always returned.

    Returns

    Number

    One of CKEDITOR.EVENT_PHASE_CAPTURING, CKEDITOR.EVENT_PHASE_AT_TARGET, or CKEDITOR.EVENT_PHASE_BUBBLING.

  • getTarget() → node

    Returns the DOM node where the event was targeted to.

    var element = CKEDITOR.document.getById( 'myElement' );
    element.on( 'click', function( ev ) {
        // The DOM event object is passed by the 'data' property.
        var domEvent = ev.data;
        // Add a CSS class to the event target.
        domEvent.getTarget().addClass( 'clicked' );
    } );
    

    Returns

    node

    The target DOM node.

  • preventDefault( [ stopPropagation ] )

    Prevents the original behavior of the event to happen. It can optionally stop propagating the event in the event chain.

    var element = CKEDITOR.document.getById( 'myElement' );
    element.on( 'click', function( ev ) {
        // The DOM event object is passed by the 'data' property.
        var domEvent = ev.data;
        // Prevent the click to chave any effect in the element.
        domEvent.preventDefault();
    } );
    

    Parameters

    [ stopPropagation ] : Boolean

    Stop propagating this event in the event chain.

    Defaults to false

  • stopPropagation()

    Stops this event propagation in the event chain.