Unable to suppress browser shortcut keys (CTRL+N, CTRL+S) from WebExtension popup

Hello,

My WebExtension has some of its UI in web pages that are displayed in a browser popup window (specificially, the window type passed to browser.windows.create() is “detached_panel”). I’ve set up an event listener for the “keypress” event and want to use CTRL+N in the WebExtension popup window. But pressing CTRL+N opens a new browser window with the same size as the WebExtension popup. I’ve noticed that the other standard Firefox browser keys are also functioning in my popup window (e.g. CTRL+S to save the page), which I don’t want. I tried using event.preventDefault() but it has no effect. I also tried changing the window type to “popup”, but again it doesn’t change anything. Any ideas? Thanks in advance.

Apparently Firefox just doesn’t care.

document.onkeydown = event => { console.log(event); event.preventDefault(); }

stops the page save option in Chrome, but has no effect in Firefox on either web or extension pages.

Opening a new window probably can’t and shouldn’t be prevented (but inheriting the size from the panel is stupid, as is the fact that Firefox opens new tabs created with browser.tabs.create({ }) inside the popup by default).

So if you care about this, you’ll need to open a bug and wait a couple of years until maybe someone bothers to fix it.