-1

I would like to disable shortcut "CTRL+A" on specific window,

Here is my current code based on Electron docs

electronLocalshortcut.register(app..main, 'Ctrl+A', () => {
   console.log('prevent ctrl+a');
});

I'm able to catch "CTRL+A" event but I'm not able to prevent select all effect it still select all items on the page, app bar etc

Loki
  • 1,064
  • 2
  • 26
  • 55

1 Answers1

1

In your renderer (window) process, add a keydown listener, it will allow you to prevent any shortcuts you want:

document.addEventListener('keydown', keyDownHandler)

function keyDownHandler (event) {
  if (event.ctrlKey && event.code === 'KeyA') {
    event.preventDefault()
  }
}
AlekseyHoffman
  • 2,438
  • 1
  • 8
  • 31