Shortcuts messing with canvas focus

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?

I have found a solution:

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();
}
2 Likes