Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 901
Jason Louro Avatar asked Jul 10 '26 18:07

Jason Louro


1 Answers

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">
like image 126
Darren Avatar answered Jul 13 '26 09:07

Darren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!