Override standart actions for 'alt+click', 'ctrl+click', 'shift+click', etc

WebViewer Version: 8.3.3

Please give a brief summary of your issue:
Hello, I’m writing this message because I have ran into a problem with default key mappings. Main problem is that I couldn’t find a way to off or override standard actions for ‘alt+click’, ‘ctrl+click’, ‘shift+click’, etc. It’s important cases for functionality of our application. Is there any way to solve this problem?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Dmitry,

One way to create custom actions for click events is to use the addEventListener('leftMouseDown',...) API.

https://www.pdftron.com/api/web/Core.DocumentViewer.html#event:mouseLeftDown

An example of using this event with keyboard keys would look like this:

addEventListener('mouseLeftDown', (e)=> 
  if(e.ctrlKey) { 
    console.log('ctrl+click')
 } )

Here is a link to documentation on supported keyboard hotkeys:

https://www.pdftron.com/api/web/UI.Hotkeys.html#main

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.
www.pdftron.com

Thank you for the answer, but the issue is not in creating custom actions, the problem is that I can’t override or remove listener for default actions.

For example: ‘alt+click’ on annotation creates its copy and I can’t find a way to change this behavior. Of cource, you may delete it right after creation using ‘annotationChanged’ event when ‘alt’ was pressed, but it looks like crutch and not a good solution.

Another one: ‘ctrl+click’ opens context menu popup and I also can’t change it to custom action. The only solution is to handle context menu open and close it right after when ‘ctrl’ was pressed, but again not clear and context menu popup still appears for a second before close.

And finally, on creation of LineAnnotation using distance measurement tool I can’t use ‘shift+click’ event, because when you hold ‘shift’ tool uses fixed angles like 0, 45, 90, etc., I also couldn’t find a way to change this behavior. It also can be helpful if we can change this angles step, for example, to use 15 instead of 45: 0, 15, 30, etc.

I see the issue now.

Unfortunately there is no API currently to disable/override these events. We have added this functionality to the backlog and will introduce this in a later version of WebViewer.