Skip to content

How to disable right-clicking #2235

Answered by tis-starlight
rafisics asked this question in Q&A
Discussion options

You must be logged in to vote

Although these properties are deprecated, they may still function in certain environments.

Here is an updated script that avoids using deprecated properties:

document.addEventListener('keydown', function (event) {
  if (event.key === 'F12' || event.key === 'Alt') {
    event.preventDefault();
  }
});

document.addEventListener('contextmenu', (event) => event.preventDefault());

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@rafisics
Comment options

Comment options

You must be logged in to vote
4 replies
@rafisics
Comment options

@guillermodotn
Comment options

@rafisics
Comment options

@rafisics
Comment options

Comment options

You must be logged in to vote
3 replies
@rafisics
Comment options

@tis-starlight
Comment options

Answer selected by rafisics
@rafisics
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants