Reputation: 19
I am working on a site which requires me to send F1 and F11 as a way to progress with the script
However, while running on chrome, F1 opens a new Tab and F11 switches to Theater mode, Both are undesired consequences of using the F Keys
Is there a way, using Code, to disable the F1 & F11 keys functionality?
Thanks
Upvotes: 0
Views: 156
Reputation: 76
You prevent them with a keydown handler, keep in mind that while this does block entering fullscreen/theater mode, it is not able to prevent exiting fullscreen mode.
document.addEventListener("keydown", e => {
if(e.key == "F1" || e.key == "F11")
{
e.preventDefault();
}
});
You can find a jsfiddle to test it here: https://jsfiddle.net/od6gbpru/
Upvotes: 1