Jason Louro
Jason Louro

Reputation: 39

Electron: Disable Paste on Windows

I am using Electron and I'm trying to disable the ability for users to paste into editable content. I'm also keeping paste and match style enabled. This works great on Mac, but for some reason on Windows, normal paste is still possible even when there is no key accelerator that points to a paste function. How can I disable this?

Upvotes: 3

Views: 351

Answers (1)

Darren
Darren

Reputation: 718

Return false for the input's onpaste function.

For example:

document.querySelector('.noPaste').onpaste = () => false;
You can paste into this one:
<input>
<br/>
You can't paste into this one:
<input class="noPaste">

Upvotes: 2

Related Questions