Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
¿Puedo evitar el cuadro de diálogo de impresión del sistema ctrl + shift + p en las ventanas del navegador?

Me gustaría usar la combinación de teclas ctrl + shift + p para abrir una paleta de comandos similar a cómo se abre en https://vscode.dev . Esto parece funcionar bien en navegadores en MacOS, sin embargo, cuando intento hacer lo mismo en Windows, se abrirá un cuadro de diálogo de impresión del sistema.

He intentado agregar un detector de eventos para 'beforeprint' pero no creo que se pueda cancelar.

 window.addEventListener('beforeprint', (event) => { event.preventDefault(); event.stopPropagation(); });

Estoy tratando de evitar el cuadro de diálogo de impresión en este controlador para la combinación de teclas

 document.addEventListener('keydown', (event) => { if (event.key === 'p' && event.shiftKey && (event.ctrlKey || event.metaKey)) { // Prevent browser print dialog event.preventDefault(); // Prevent dev tools command palette from opening event.stopPropagation(); // Do logic here } });

Este controlador parece funcionar bien en MacOS Safari y Chrome, pero no puedo replicar el comportamiento en Windows, donde abre el cuadro de diálogo de impresión del sistema.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Pude resolver este problema cambiando mi verificación de event.key === 'p' a event.keyCode === 80 . No necesitaba el controlador 'beforePrint' .

 document.addEventListener('keydown', (event) => { if (event.keyCode === 80 && event.shiftKey && (event.ctrlKey || event.metaKey)) { // Prevent browser print dialog event.preventDefault(); // Prevent dev tools command palette from opening event.stopPropagation(); // Do logic here } });
about 4 years ago · Juan Pablo Isaza Report

0

Si está usando/puede usar jQuery :

 $(document).bind("keyup keydown", function(e) { if (e.ctrlKey && e.keyCode == 80) { alert("Do what ever you want here.") return false; // Stops print } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Si lo ejecuta aquí, no funcionará. Intente ejecutarlo en codepen o en otro lugar.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!