Here's the code I wrote:
This also works for images, text and other types of content. However, you can still access the "Inspect" and the "View source" tool through keyboard shortcuts. (As the answer at the top says, you can't stop it entirely.) But you can try to put barriers up to stop them, such as the one above