Jquery:单击以触发keydown事件

时间:2013-06-28 09:09:39

标签: jquery fullscreen onkeydown eventtrigger

如何在单击按钮时触发keydown事件?

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

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

单击按钮时,我想在键盘上触发 F11 键。有可能吗?

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的方法并将其调整为122:

Is it possible to simulate key press events programmatically?

否则,如果您尝试全屏 - 为什么两者都使用F11?:

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