CKEDITOR.dom.event
Represents a native DOM event object.
Filtering
Properties
-
The native DOM event object represented by this class instance.
Methods
constructor( domEvent ) → eventCKEDITOR.dom.event#constructorCreates an event class instance.
Parameters
domEvent : ObjectA native DOM event object.
Returns
event
getKey() → NumberCKEDITOR.dom.event#getKeyGets the key code associated to the event.
alert( event.getKey() ); // '65' if 'a' has been pressedReturns
NumberThe key code.
getKeystroke() → NumberCKEDITOR.dom.event#getKeystrokeGets 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' keyReturns
NumberThe number representing the keys combination.
getPageOffset() → ObjectCKEDITOR.dom.event#getPageOffsetRetrieves 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
ObjectThe object contains the position.
Propertiesx : Numbery : Number
getPhase() → NumberCKEDITOR.dom.event#getPhaseReturns 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
getTarget() → nodeCKEDITOR.dom.event#getTargetReturns 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
nodeThe target DOM node.
preventDefault( [ stopPropagation ] )CKEDITOR.dom.event#preventDefaultPrevents 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 ] : BooleanStop propagating this event in the event chain.
Defaults to
false
stopPropagation()CKEDITOR.dom.event#stopPropagationStops this event propagation in the event chain.