Is it possible to simulate a keypress when I click a div? Something like:
$("mydiv").click(function(){
Presskey->F5
});
Actually the key I'm trying to simulate is F11, so people could press the div and the window would fullscreen. I've searched this and I know it's not possible to make window fullscreen without the user "permission" but in this case he would press the div as he pressed the key. The fact is not everyone knows about F11 (I know I could always put "Press F11 for fullscreen"). Thanks'
Yes you can simulate F11 being pressed, but you can't simulate what that does, which is a native browser function (as it would only have an effect in the JavaScript VM area), and not one triggered by JavaScript.
"Press F11 for fullscreen" is your best option here, think of the security issues if you could trigger any browser behavior from JavaScript, e.g. Ctrl+S
, etc.
As an aside, this is true even in other areas, for example you can simulate a click
event on an anchor and it'll trigger all the JavaScript goodness hooked up to it...but it won't actually follow the link, some (most) things in a browser happen above the JavaScript level, where you don't have access to anything.