wong2 wong2 - 16 days ago 4x
jQuery Question

Why trigger F11 press event doesn't work?

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 can simulate press F11 to get things work.

I learned that I can use trigger in JQuery to simulate key press event, so I do something like this:

$("body").keyup(function (e) {
var e = $.Event("keyup");
e.which = 122; // # Key code of F11

When I run this, I got the alert says 122, but it seems that it doesn't give the hoped result. Is there a restriction there?

I made a fiddle here: http://jsfiddle.net/ap295/5/

Val Val

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

       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.