0

How can I trigger a keydown event when a button is clicked?

var e = jQuery.Event("keydown");
    e.which = 122; // # Some key code value

    $('.button-fullscreen').click(function(){
        $(window).trigger(e);
        return false;
    });

I want to trigger the key F11 on the keyboard when the button is clicked. Is it possible?

Run
  • 54,938
  • 169
  • 450
  • 748
  • use full screen API to full screen https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Using_full_screen_mode – bugwheels94 Jun 28 '13 at 09:14
  • i have tried that. it does not work with my layout as my website layout has a horizontal scrollbar at the bottom page. – Run Jun 28 '13 at 09:24

1 Answers1

1

You could try something like this and adapt it to 122:

Is it possible to simulate key press events programmatically?

Otherwise, if you are trying to fullscreen - why both with F11?:

How to make the window full screen with Javascript (stretching all over the screen)

Community
  • 1
  • 1
ddoor
  • 5,819
  • 9
  • 34
  • 41
  • i have tried that one - http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen but it does not work with my layout. thanks. – Run Jun 28 '13 at 09:28