Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
How do I detect a keydown event in google docs with a JS bookmarklet?

I have been trying to make a JS bookmarklet that will make a sound on any keydown and keyup events, and on most websites it's been working. However, it doesn't work in google docs, where I wanted to use it the most. This may sound like a duplicate of this question, but I promise that I tried all of the solutions and they did not work, probably because the question's from 11 years ago. Here's my code:

function random(min,max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min + 1) + min);
}

function makeListeners(kind) {
  const generic = [];
  const space = [];
  const enter = [];
  const backspace = [];

  for (let x = 0;x < 3;x++) {
    generic.push(new Audio(`https://you-dont-need-to-know-my-website.com/audio1.mp3`));
    space.push(new Audio(`https://you-dont-need-to-know-my-website.com/audio2.mp3`));
    enter.push(new Audio(`https://you-dont-need-to-know-my-website.com/audio3.mp3`));
    backspace.push(new Audio(`you-dont-need-to-know-my-website.com/audio4.mp3`));
  }
  document.addEventListener(kind, function(e) {
    if (e.code != 'Space' && e.code != 'Enter' && e.code !='Backspace') {
      generic[random(0,2)].play();
    }
    else {
      eval(e.code.toLowerCase())[random(0,2)].play();
    }
  });
}

makeListeners('keydown');
makeListeners('keyup');
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda