Disabling copy paste (cntrl +c, cntrl +v) from the site

Is there a way to do that?
besides disabling right click on the site.

http://www.hypergurl.com/norightclick.html
Boom :smiley:

Thanks @Waldo_Broodryk, i was wondering where you are! :smile:

But that’s for disabling right click, i can still highlight a text section and then (cntrl +c, cntrl +v) copy paste them, how do i disable that?

Haha, it has information on how to do it is on the page. :slight_smile: I’ll type of our once I’m home :grin:

Should just be the following @Nir. Add the following html code to your BODY tag:

<body ondragstart="return false" onselectstart="return false">

Haven’t tested it yet.

1 Like

Wrap this with <script></script> tags and put it in Footer Code in site dashboard Custom Code section.
You can adjust that to ANY character pressed with CTRL key. Look at the following website with keycodes: Javascript Char Codes (Key Codes) - Cambia Research

You’re welcome :)

$(document).keydown(function(e) {
  // 67 == C
  if (e.keyCode == 67 && e.ctrlKey) {
    e.preventDefault();
    console.log('no no no. you cant ctrl+c');
  }

  // 86 == V
  if (e.keyCode == 86 && e.ctrlKey) {
    e.preventDefault();
    console.log('no no no. you cant ctrl+v');
  }
});
2 Likes

@bartekkustra You are truly the Javascript ninja! Thanks man!!!

1 Like

1 Like

What about for macs? Do I just change the ctrl to cmd?

Unlike Shift/Alt/Ctrl, Mac/Apple key is not considered as a modifier key–instead, you should hook on keydown/keyup and record when a key is pressed and then depressed based on event.keyCode.

Unfortunately, these key codes are browser-dependent:

Firefox: 224
Opera: 17
WebKit (Safari/Chrome): 91 (Left Apple) or 93 (Right Apple)

from

@bartekkustra your awesomeness is awesome.

Thank you!

1 Like

@bartekkustra hope you don’t mind me asking you another question.

Have any idea how to create this “soft” scrolling effect?
http://www.werkstatt.fr

Just to ease the scrolling so it wont be so “sharp”.

Thank you!

I don’t mind :) Unfortunately for now I have no idea how to create such thing… I might need to work on that. Drop me that question at www.barts.work so I won’t forget that.

Hi @bartekkustra thanks! Just did.

@bartekkustra this kinda works, not 100% the same like the link, but it does the job.

var $window              = $(window),
scrollDistance   = 170,
scrollSpeed      = 400,
scrollEffect     = 'swing',
scrollAmount     = 1,
smoothScroll;

if (! (‘ontouchstart’ in document.documentElement) && ! $(‘body’).hasClass(‘modal-open’)) {

    $window.on("mousewheel DOMMouseScroll", function (event) {

        event.preventDefault();

        if (smoothScroll) {

            // Start scrolling while waiting for final scoll amount (user stopped wheeling)
            if (scrollAmount == 1) {
                var delta = event.originalEvent.wheelDelta / 120 || -event.originalEvent.detail / 3;
                var finalScroll = $window.scrollTop() - parseInt(delta * (scrollDistance * scrollAmount));

                $('html, body').stop().animate({ scrollTop: finalScroll }, scrollSpeed, scrollEffect);
            }

            // Increase scroll amount
            scrollAmount++;

            // Clear current timeout
            clearTimeout(smoothScroll);
        }

        // Set animated scroll
        smoothScroll = setTimeout(function() {

            var delta = event.originalEvent.wheelDelta / 120 || -event.originalEvent.detail / 3;
            var scrollTop = $window.scrollTop();
            var finalScroll = scrollTop - parseInt(delta * (scrollDistance * scrollAmount));

            // Reset scroll amoount
            scrollAmount = 1;

            $('html, body').stop().animate({ scrollTop: finalScroll },
                (scrollSpeed*scrollAmount),
                scrollEffect
            );

            // Clear timeout holder
            smoothScroll = null;

        }, 100);

    });

}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.