I am writing a script that fires a random keydown event with keyCode 37 when a button is clicked.
The following script works fine in IE, Safari, and Chrome, but it does not work in Firefox and Opera. Even if I changed {keyCode: 37} to {which: 37} , it still doesn't work.
$('button').click(function(e){ jQuery("body").trigger(jQuery.Event("keydown", {keyCode: 37})); e.preventDefault(); }
Does anyone know how to make it work in Firefox and Opera?
source share