diff --git a/changelog.txt b/changelog.txt index 7415e56d..0d2a7464 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,6 +9,7 @@ OPENSEADRAGON CHANGELOG * The "page" event is now fired after the page index has been updated (#1330) * Added option pixelsPerArrowPress that sets the speed of arrow keys (#1364) * Improved IIIF options.maxLevel calculation (#1401) +* Added canvas-key events, along with the ability to cancel key actions (#1414) 2.3.1: diff --git a/src/viewer.js b/src/viewer.js index fbceaf4f..bffb18ad 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2483,6 +2483,7 @@ function onCanvasKeyDown( event ) { preventVerticalPan: event.preventVerticalPan, preventHorizontalPan: event.preventHorizontalPan }; + /** * Raised when a keyboard key is pressed and the focus is on the {@link OpenSeadragon.Viewer#canvas} element. * @@ -2548,20 +2549,8 @@ function onCanvasKeyPress( event ) { preventVerticalPan: event.preventVerticalPan, preventHorizontalPan: event.preventHorizontalPan }; - /** - * Raised when a keyboard key is pressed and the focus is on the {@link OpenSeadragon.Viewer#canvas} element. - * - * @event canvas-key - * @memberof OpenSeadragon.Viewer - * @type {object} - * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event. - * @property {Object} originalEvent - The original DOM event. - * @property {Boolean} preventDefaultAction - Set to true to prevent default keyboard behaviour. Default: false. - * @property {Boolean} preventVerticalPan - Set to true to prevent keyboard vertical panning. Default: false. - * @property {Boolean} preventHorizontalPan - Set to true to prevent keyboard horizontal panning. Default: false. - * @property {?Object} userData - Arbitrary subscriber-defined object. - */ + // This event is documented in onCanvasKeyDown this.raiseEvent('canvas-key', canvasKeyPressEventArgs); if ( !canvasKeyPressEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {