Created
June 9, 2017 12:11
-
-
Save JBlond/10c5501f6c291dc11e0f3f74848d3b2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Ctrl+c Ctrl+v disabled</h3> | |
<textarea class="no-copy-paste"></textarea> | |
<br><br> | |
<h3>Ctrl+c Ctrl+v allowed</h3> | |
<textarea></textarea> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var ctrlDown = false, | |
ctrlKey = 17, | |
cmdKey = 91, | |
vKey = 86, | |
cKey = 67; | |
$(document).keydown(function(e) { | |
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true; | |
}).keyup(function(e) { | |
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false; | |
}); | |
$(".no-copy-paste").on({ | |
keydown: function(event){ | |
if(ctrlDown && (event.keyCode == vKey || event.keyCode == cKey)){ | |
alert('GOT YA'); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment