0

I want to written function to all kind of screenshots and prints. Now I want to write function for right click and print in Angular. If anyone knows to crack that do let me know. Sample code is as below

  document.addEventListener('keydown', (e) => {
  if (e.ctrlKey && e.key == 'p') {
    // console.log("tried to print")
    // alert('This section is not allowed to print or export to PDF');
    this.prtScrEvent("Screenshot");
  }
});
//prtsc key press
window.addEventListener("keyup", (e) => {
  if (e.keyCode == 44) {
    // console.log("printing tried");
    // alert("The 'print screen' key is pressed");
    this.prtScrEvent("Screenshot");
  }
});

async prtScrEvent(status) {....}
Ashwin S E
  • 11
  • 2
  • Does this answer your question? [Bind event to right mouse click](https://stackoverflow.com/questions/706655/bind-event-to-right-mouse-click) – freedomn-m Sep 20 '21 at 10:10

1 Answers1

0

See if this helps for right-click.

document.addEventListener('contextmenu', (e) =>{
    // Your code
})