From 622e39eabf8c9e007c6fb85dba0a448f22ddc7ef Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Mon, 13 Feb 2023 08:29:42 -0800 Subject: [PATCH] Added properties to MouseTracker keydown/keyup/keypress events --- src/mousetracker.js | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/mousetracker.js b/src/mousetracker.js index 5854d923..9b047b6e 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -885,7 +885,13 @@ * @param {OpenSeadragon.MouseTracker} event.eventSource * A reference to the tracker instance. * @param {Number} event.keyCode - * The key code that was pressed. + * The key code that was pressed (legacy DOM event model). + * @param {String} event.key + * The key value of the key pressed. + * @param {String} event.code + * The code value associated with the key’s physical placement on the keyboard. + * @param {Number} event.location + * The location of the key on the device. * @param {Boolean} event.ctrl * True if the ctrl key was pressed during this event. * @param {Boolean} event.shift @@ -911,7 +917,13 @@ * @param {OpenSeadragon.MouseTracker} event.eventSource * A reference to the tracker instance. * @param {Number} event.keyCode - * The key code that was pressed. + * The key code that was pressed (legacy DOM event model). + * @param {String} event.key + * The key value of the key pressed. + * @param {String} event.code + * The code value associated with the key’s physical placement on the keyboard. + * @param {Number} event.location + * The location of the key on the device. * @param {Boolean} event.ctrl * True if the ctrl key was pressed during this event. * @param {Boolean} event.shift @@ -937,7 +949,13 @@ * @param {OpenSeadragon.MouseTracker} event.eventSource * A reference to the tracker instance. * @param {Number} event.keyCode - * The key code that was pressed. + * The key code that was pressed (legacy DOM event model). + * @param {String} event.key + * The key value of the key pressed. + * @param {String} event.code + * The code value associated with the key’s physical placement on the keyboard. + * @param {Number} event.location + * The location of the key on the device. * @param {Boolean} event.ctrl * True if the ctrl key was pressed during this event. * @param {Boolean} event.shift @@ -1804,7 +1822,10 @@ if ( tracker.keyDownHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) { eventArgs = { eventSource: tracker, - keyCode: event.keyCode ? event.keyCode : event.charCode, + keyCode: event.keyCode || event.charCode, + key: event.key || '', + code: event.code || '', + location: event.location || 0, ctrl: event.ctrlKey, shift: event.shiftKey, alt: event.altKey, @@ -1846,7 +1867,10 @@ if ( tracker.keyUpHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) { eventArgs = { eventSource: tracker, - keyCode: event.keyCode ? event.keyCode : event.charCode, + keyCode: event.keyCode || event.charCode, + key: event.key || '', + code: event.code || '', + location: event.location || 0, ctrl: event.ctrlKey, shift: event.shiftKey, alt: event.altKey, @@ -1888,7 +1912,10 @@ if ( tracker.keyHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) { eventArgs = { eventSource: tracker, - keyCode: event.keyCode ? event.keyCode : event.charCode, + keyCode: event.keyCode || event.charCode, + key: event.key || '', + code: event.code || '', + location: event.location || 0, ctrl: event.ctrlKey, shift: event.shiftKey, alt: event.altKey,