Copy the code code as follows:
<script type="text/javascript">
function jumpPage() {
if (event.keyCode==37)//left
fun_a();
if (event.keyCode==38)//Up
fun_b();
if (event.keyCode==39)//right
fun_c();
if (event.keyCode==40)//Next
fun_d();
}
function fun_a(){
window.alert('You pressed left')
}
function fun_b(){
window.alert('You pressed up')
}
function fun_c(){
window.alert('You pressed the right')
}
function fun_d(){
window.alert('You pressed it')
}
document.onkeydown=jumpPage;
</script>
HTML code
Copy the code code as follows:
<table cellspacing="1" cellpadding="0" id=table> <tr id="lineone" style="background-color:#00cccc;"> <td id=aa></td> <td id=aa >Press down key</td> <td id=cc >Press down key</td> <td id=dd >Press down key</td> <td id=ee >Press down key</td > </tr> <tr id="linetwo" tyle="background-color:#ffffff;"> <td id=a></td> <td id=b >Press the up key</td> <td id= c >Press the up key</td> <td id=d >Press the up key</td> <td id=e >Press the up key</td> </tr></table><script language="javascript" > function keyDown(e) { var iekey=event.keyCode; action(iekey); } document.onkeydown = keyDown; function action(iekey) { if(iekey==40) { lineone.style.backgroundColor = ""; linetwo.style .backgroundColor = "#00cccc"; } if(iekey==38) { lineone.style.backgroundColor = "#00cccc"; linetwo.style.backgroundColor = ""; } } </script><input name="id" type="hidden" id="id" value