Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
Is there any way to detect Ctrl + S?

I need to write a page which does not allow the user to see the code. To catch the context menu open I want to use the JS event. To catch web-console open I want to use this: https://sindresorhus.com/devtools-detect/ and close the page. How to catch saving? Is it enough to catch Ctrl+S?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

No, trapping ctrl + s will only solve the case where the user uses a keyboard shortcut (be sure to remember it's cmd+s for Macs). They will still get the save webpage dialog if they use the File Menu or the context menu's "Save As" action. I have never heard of a way to trap those.

You will never be able to prevent the user from seeing your code, if the browser can download and execute it, the user can see it, whether through curl, a packet sniffer or DevTools.

The best you can do is obfuscate your code, which anyone with enough skills will be able to turn in to non-obfuscated code.

about 4 years ago · Juan Pablo Isaza Relatório

0

We can listen for keydown. If the ctrlKey and S key are being pressed, do the work. The preventDefault is preventing the save page dialog from opening up.

document.addEventListener('keydown', (e) => {
  if (e.ctrlKey && e.key === 's') {
    e.preventDefault();
    console.log('pressing ctrl+s')
  }
});

But preventing a user from seeing your code? That's a different story. We can detect Ctrl+S, but not prevent someone from seeing your code.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda