如何在单击按钮时触发keydown事件?
var e = jQuery.Event("keydown");
e.which = 122; // # Some key code value
$('.button-fullscreen').click(function(){
$(window).trigger(e);
return false;
});
单击按钮时,我想在键盘上触发 F11 键。有可能吗?
答案 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)