# Unable to switch off annotation tools or disable the hotkeys

**URL:** <https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386>\
**Category:** Bug Reports\
**Tags:** pdfjs-express\
**Created:** [February 21, 2023, 6:25pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386 "2023-02-21T18:25:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![polina.meleca](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@polina.meleca](https://pdfjs.community/u/polina.meleca)\
**Post date:** [February 21, 2023, 6:25pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386/1 "2023-02-21T18:25:56Z")

</div>

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:

```javascript
    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

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [February 22, 2023, 6:50pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386/2 "2023-02-22T18:50:08Z")

</div>

Hi there,

Thanks for contacting pdf.js express forums,

Disabling the tools should automatically disable the hotkey as well:

> **[Customize PDF.js Express Viewer Annotations in Toolbar | Documentation](https://pdfjs.express/documentation/annotation/customizing-tools.8#disable/enable-tools)**

If the above does not work for you, could you please try disabling via enum:  
[https://pdfjs.express/api/UI.html#.disableTools\_\_anchor](https://pdfjs.express/api/UI.html#.disableTools__anchor)  
e.g.

```javascript
    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

---

<div class="post-metadata">

**Author:** ![polina.meleca](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@polina.meleca](https://pdfjs.community/u/polina.meleca)\
**Post date:** [April 26, 2023, 3:42pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386/3 "2023-04-26T15:42:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [April 26, 2023, 5:50pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386/4 "2023-04-26T17:50:32Z")

</div>

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](https://pdfjs.express/api/Core.Tools.html#.ToolNames__anchor)

The revised code is the following:

```javascript
    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

---

<div class="post-metadata">

**Author:** ![polina.meleca](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@polina.meleca](https://pdfjs.community/u/polina.meleca)\
**Post date:** [May 2, 2023, 5:42pm UTC](https://pdfjs.community/t/unable-to-switch-off-annotation-tools-or-disable-the-hotkeys/2386/5 "2023-05-02T17:42:29Z")

</div>

> [@kkim](#):
>
> `const { Tools } = instance.Core;`

It works for me this way, thank you
