I’m writing a script which triggers an artificial keydown event with keyCode 37 when
button is clicked.
The following script works fine on IE, Safari, and Chrome, but it doesn’t work on Firefox and Opera. Even if I change {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 on Firefox and Opera?
try this, if a browser doesn’t support
which, it will supportkeyCode