-1

I want to detect the clipboard in my electron app. Know someone who can answer?

1 Answers1

0

It was the issue because Electron doesn't support the change event of the clipboard. https://github.com/electron/electron/issues/2280

But thankfully, sudhakar3697 developed a node module node-clipboard-event which supports clipboard change event for Node.js/Electron.js/NW.js.

Using it, you can listen to the event in this way.

const clipboardListener = require('clipboard-event');

// To start listening
clipboardListener.startListening();

clipboardListener.on('change', () => {
    console.log('Clipboard changed');
});

// To stop listening
clipboardListener.stopListening();
koko-js478
  • 1,703
  • 7
  • 17
  • node module node-clipboard-event just support win32 & linux, doesn't work on mac – a little hamster Sep 24 '20 at 02:04
  • try to use [node-clipboard](https://www.npmjs.com/package/clipboard) like [this answer](https://stackoverflow.com/questions/8584597/how-can-i-listen-for-clipboard-events-in-node-js?answertab=votes#tab-top) – koko-js478 Sep 24 '20 at 08:21