Why trigger F11 press event doesn't work?

前端 未结 4 953
梦毁少年i
梦毁少年i 2020-12-06 11:24

I just read this question: Full Screen Page by pressing button instead of F11
The op asked to replace F11 with other hot keys, so I\'m wondering that maybe I

4条回答
  •  长情又很酷
    2020-12-06 12:12

    I think this is the one :) to detect it ...

    $(document).keyup(function(e){
       if(e.which==122){
           e.preventDefault();//kill anything that browser may have assigned to it by default
           //do what ever you wish here :) 
           alert('F11 pressed');
           return false;
       }
    });
    

    but triggering it (NOT POSSIBLE)

    But you will not prevent the browser from full screen :) ... Reson given is that , lets say I have full screened it somehow, and wish to toggle out of it using F11 but u are preventing me, I would have to restart PC, [computer illiterates] which poses security risk as you are preventing a user from doing something he is expecting to do, and they may think PC is broken or something :) so ...there you are.

提交回复
热议问题