Protecting webpage text from being selected
That is an old skool question, the common wisdom is that you cannot prevent a user from getting to the text. There are a number of ways to get around your protection.

For example, in Chrome, open Developers Tools, open your site, check the web request, and then all the text will be perfectly copy pastable.

Other than that:


alert() has been a bad practice for 20 years now, please use something else
Indent your code, use jsbeautifier if you have trouble
In the keydown, I would check whether the control key is pressed before throwing an error, unless the user never needs to press PageUp or PageDown
I am not entire surely, but I think you will need event.preventDefault(); to really prevent right clicking etc.