Reputation: 2812
Is it possible to disable an specific key combination? CTRL + U for example?
I don't want to allow the user to press ctrl + u in order to see my javascript code. I only had disabled the left click but i would like more "protection".
Thanks!
Upvotes: 2
Views: 2274
Reputation: 42757
You can't prevent people from looking at your javascript code. Developers (the only folks who really want to look at it) will find ways to see it, no matter what you do.
Instead if you want to protect it, make it hard to understand when they do see it. The easiest way is to obfuscate it. Minifying does a reasonable job of making javascript hard to understand. But check out this SO question for more ideas. How can I obfuscate (protect) JavaScript?
Upvotes: 0
Reputation: 1483
You'll never stop users being able to view source on a site - plus it goes against the open nature of the web. I wouldn't waste your time on it, put those efforts into making stuff people can use rather than preventing them seeing what you're doing.
Upvotes: 0
Reputation: 25776
This will only offer so much protection, if the user knows his\her way around the browser they would be able to see your javascript from say the web developer tools and many many other ways. Remember the information is downloaded to your computer so eventually they can find the files.
$(document).on('keydown',function(e){
if( e.ctrlKey === true && e.which === 85 )
return false;
});
Upvotes: 2