jquery.nocutcopypaste.js 808 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Created with JetBrains PhpStorm.
  3. * User: albert1t0
  4. * Date: 24/04/13
  5. * Time: 04:33 PM
  6. * This is a little script to prevent Cut Copy Paste Actions in Browser.
  7. * At this time for exercise form.
  8. */
  9. $(document).ready(function(){
  10. $(document).live("cut copy paste contextmenu",function(e) {
  11. e.preventDefault();
  12. });
  13. $(document).keydown(function(e) {
  14. var forbiddenKeys = new Array('c', 'x', 'v');
  15. var keyCode = (e.keyCode) ? e.keyCode : e.which;
  16. var isCtrl;
  17. isCtrl = e.ctrlKey
  18. if (isCtrl) {
  19. for (i = 0; i < forbiddenKeys.length; i++) {
  20. if (forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) {
  21. return false;
  22. }
  23. }
  24. }
  25. return true;
  26. });
  27. });