title: How to disabled Ctrl+P and Ctrl+S? in ng2-pdfjs-viewer. Right now anyone can print or download using keys.Any suggestion would be appreciated would
body: <p>I am using ng2-pdfjs-viewer library to display pdf in my angular 7 app. Problem is if print flag is false button to print is not visible that works as expected but user can right click or use CTRL+P or CTRL+S and print or download the pdf. I want to restrict user to use those keys. I tried using JavaScript methods in my dom but those are not working as PDFJS component is overlapping.After all i tried to modify viewer.js file under node_modules folder that worked for me in my machine but we are using Jenkins build tool which use files from SVN and i can not commit node_modules to SVN. Jenkins use libraries from server on the base of package.json so my modification is use less in this case.I tried onBeforePrint event as well that is not invoked don't know why. Please help me on this how we can do that alternatively. Your help will be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>writing down the code i tried to modify the viewer.js</p>
  
  <p>Code in my component</p>
  
  <pre class="lang-py prettyprint-override"><code>&lt;mat-dialog-content class="my-2 d-flex justify-content-center px-2"&gt;
    &lt;div class="w-100 h-100"&gt;
      &lt;ng2-pdfjs-viewer [download]="isPrintable" (onBeforePrint)="beforePrint()" [print]="isPrintable" *ngIf="pdfContent" [pdfSrc]="pdfContent"&gt;&lt;/ng2-pdfjs-viewer&gt;
  &lt;/div&gt; 
  &lt;/mat-dialog-content&gt;
  </code></pre>
  
  <p>viewer.js modifications</p>
  
  <pre class="lang-py prettyprint-override"><code>//To disable right click print added by KK on 29/08/2019
  window.oncontextmenu = function () {
  return false;
  }
  var hasAttachEvent = !!document.attachEvent;
  window.addEventListener('keydown', function (event) {
  
    //code to prevent download and print using CTRL+S and CTRL+P added by KK on 29/08/2019
    if ((event.keyCode === 80 || event.keyCode === 83) &amp;&amp; (event.ctrlKey || event.metaKey) &amp;&amp; !event.altKey &amp;&amp; (!event.shiftKey || window.chrome || window.opera)) {
      //window.print();
  
      if (hasAttachEvent) {
        return;
      }
  
      event.preventDefault();
  
      if (event.stopImmediatePropagation) {
        event.stopImmediatePropagation();
      } else {
        event.stopPropagation();
      }
  
      return;
    }
  
  }, false);
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code> // CTRL + P key combinations you want to disable
    @HostListener('document:keydown', ['$event']) onKeydownHandler(event: KeyboardEvent) {
      if (event.ctrlKey &amp;&amp; event.keyCode === 80) {
        return false;
      }
    }
  </code></pre>