Skip to content

How to listen to keyboard events in electron without interrupting default behavior?

I was trying to listen to Ctrl-C event using electron globalShortcut module, but as it seems, electron is re-writing default behavior automatically (without features like preventDefault in plain javascript).

Here’s what I did:

app.whenReady().then(() => {
  const test: boolean = globalShortcut.register('CommandOrControl+C', () => {

  /* ... */

Is there an another way to listen to global keyboard shortcut events using electron without interrupting their default behavior?


This seems to be Electron’s expected behaviour

You can use iohook to capture key presses instead of Electron’s globalShortcut module