# Shortcuts messing with canvas focus

**URL:** https://meta.discourse.org/t/shortcuts-messing-with-canvas-focus/195742
**Category:** Support
**Tags:** keyboard-shortcuts
**Created:** [July 2, 2021, 8:11am UTC](https://meta.discourse.org/t/shortcuts-messing-with-canvas-focus/195742 "2021-07-02T08:11:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![morgoth90](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/morgoth90/32/226285_2.png) [@morgoth90](https://meta.discourse.org/u/morgoth90)
#### Post date: [July 2, 2021, 8:11am UTC](https://meta.discourse.org/t/shortcuts-messing-with-canvas-focus/195742/1 "2021-07-02T08:11:52Z")

</div>

I have added a webgl canvas on the top, the keyboard input works fine but I’m having a problem:  
when the canvas is focused discourse still trigger the keyboard shortcuts.

It’s possible to disable all the shortcuts? Alternatively, there is something I can call from javascript to manage the focus correclty?

---

<div class="post-metadata">

### Author: ![morgoth90](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/morgoth90/32/226285_2.png) [@morgoth90](https://meta.discourse.org/u/morgoth90)
#### Post date: [July 2, 2021, 8:49am UTC](https://meta.discourse.org/t/shortcuts-messing-with-canvas-focus/195742/2 "2021-07-02T08:49:28Z")

</div>

I have found a solution:

```plaintext
const KeyboardShortcuts = require("discourse/lib/keyboard-shortcuts").default;
const Mousetrap = require("mousetrap").default;

var shortcutsContainer;

function EnableShortcuts()
{    
    if(shortcutsContainer == null)
        return;

    KeyboardShortcuts.init(Mousetrap, shortcutsContainer);
    KeyboardShortcuts.bindEvents();
}

function DisableShortcuts()
{ 
    if(KeyboardShortcuts != null)
        shortcutsContainer = KeyboardShortcuts.container;
        
    KeyboardShortcuts.teardown();
}

```
