diff --git a/src/mpl_widget.ts b/src/mpl_widget.ts index 7e839f92..7aa7d76c 100644 --- a/src/mpl_widget.ts +++ b/src/mpl_widget.ts @@ -757,6 +757,7 @@ export class MPLCanvasView extends DOMWidgetView { y: y, button: event.button, step: event.step, + modifiers: utils.getModifiers(event), guiEvent: utils.get_simple_keys(event), }); }; diff --git a/src/utils.ts b/src/utils.ts index 63444298..7705f5e6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -33,3 +33,20 @@ export function getContext(canvas: HTMLCanvasElement) { } return context; } + +export function getModifiers(event: MouseEvent) { + const mods = []; + if (event.ctrlKey) { + mods.push('ctrl'); + } + if (event.altKey) { + mods.push('alt'); + } + if (event.shiftKey) { + mods.push('shift'); + } + if (event.metaKey) { + mods.push('meta'); + } + return mods; +}