Very quick question about f12 behaviour

In a project I need to use the f12 key to run a function that displays some data.
How can I keep my function bind to f12 key and prevent any browser from opening devtools ?
The project will be opened in several different devices and configuring each browser is not an option.

Why must it be the f12 button? Overriding default behaviors of buttons is usually considered rude, as I understand it.

1 Like

At least add a modifier key, such as alt, shift, or ctrl.

It was petitioned that way…
It’s a project for my in-laws, they need a program that’s functionally similar to the point of sale (is that the correct translation from ‘punto de venta’?)
They’re not young and not very friendly with technology. The other program uses those keys so I want to replicate them as close as possible otherwise they won’t be able to use it

EDIT: Of course if there’s no other way I will use another key

I’m assuming you’ve got a keydown listener on the document? You can just check for the f12 key being pressed and then prevent its default behavior.

document.addEventListener('keydown', function(event) {
  if (event.key === "F12") {
   // Do whatever you want here
1 Like

Yep! That does it. Thank you so much