Keydown code now working (Firefox)

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
jimandy
New php-forum User
New php-forum User
Posts: 10
Joined: Sun May 15, 2011 5:23 pm

Sat Sep 20, 2014 10:16 pm

I snagged this code somewhere and it works fine in Safari (Mac) but not at all in Firefox (ver 33.0)
Scoured the web but can't find a fix:

Code: Select all

<script language='JavaScript' type='text/JavaScript'>
<!--
// val is whatever is passed from pressing a key and is the paramenter of function "disp"
// up-down keys disabled (commented out)

function disp(val){
alert(val);
}
// replace above with the updateTable(val) function; "val becomes the multiplier

document.onkeydown = function() {
switch (window.event.keyCode) {
case 37:;disp('Left key is pressed');break;
case 39:;disp('Right key is pressed');break;
}};
//-->
</script>
Post Reply