Unable to switch off annotation tools or disable the hotkeys

Hello. I’m trying to disable some of the annotation-related hotkeys, but instance.UI.hotkeys.off doesn’t work for annotation hotkeys. I also try to disable the related tools, but it also doesn’t work, and the tools are still available when I use the hotkeys. In the same time disabling of all the hotkeys except annotation-related ones works as expected.
My code:

    WebViewer(
      {
        ...
      },
      this.viewer.nativeElement
    ).then((instance) => {
      instance.UI.disableTools([
        'ArrowCreateTool',
        'FreeHandCreateTool',
        'CalloutCreateTool',
        'FreeTextCreateTool'
      ]);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.COMMAND_SHIFT_EQUAL);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.F);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.T);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.A);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.C);
}

The effect of this code is that Cmd+Shift+= hotkey is indeed disabled, but I still can use ArrowCreateTool, FreeHandCreateTool, CalloutCreateTool, FreeTextCreateTool with the corresponding hotkeys.
pdfjs-express version is 8.7.1

Hi there,

Thanks for contacting pdf.js express forums,

Disabling the tools should automatically disable the hotkey as well:

If the above does not work for you, could you please try disabling via enum:
https://pdfjs.express/api/UI.html#.disableTools__anchor
e.g.

    const { Tools } = instance.Core;
    // disable sticky annotation tool and free text tool
    instance.UI.disableTools([Tools.ToolNames.STICKY, Tools.ToolNames.FREETEXT]);

Best regards,
Kevin Kim

Sorry for the late reply, but neither of the ways of disabling tools you’ve recommended works for me, I was able only to disable hotkeys.

Hi there,

Thank you for your response,

When going through the Tools.ToolNames we actually have 4 different default stylings for most of the tools:
https://pdfjs.express/api/Core.Tools.html#.ToolNames__anchor

The revised code is the following:

    const { Tools } = instance.Core;
    // disable sticky annotation tool and free text tool
    instance.UI.disableTools([Tools.ToolNames.ARROW, Tools.ToolNames.ARROW2, Tools.ToolNames.ARROW3, Tools.ToolNames.ARROW4]);

And you can repeat that for each of the type of Tools.

Best regards,
Kevin Kim

It works for me this way, thank you