This article is mainly about the JS keyboard up and down key how to trigger the function of a detailed analysis of the introduction, the need for friends can come to the reference, I hope to help you.
The code is as follows: <script type= "Text/javascript" > function jumppage () { if (event.keycode==37)//left & nbsp Fun_a (); if (event.keycode==38)//Upper fun_b (); if (event.keycode==39)//Right Fun_c (); if (event.keycode==40)/down 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 right ') } function Fun_d () { window.alert (' You pressed down ') } document.onkeydown=jumppage; </script> HTML code copy code code as follows: <table width= "100%" border= "1" cellspacing= "1" cellpadd ing= "0" id=table> <tr id= "Lineone" style= "Background-color: #00cccc;" > <TD id=aa height= "A" > </td> <td id=aa > Press down key </td> <TD id=cc > Press down key </td> <TD id= DD > Press DOWN ARROW </td> <TD id=ee > Press down key </td> </tr> <tr id= "LiNetwo "tyle=" Background-color: #ffffff; " > <TD id=a height= "A" > </td> <td id=b > Press up key </td> <TD id=c > Press up key </td> <TD Id=d & gt; Press up ARROW </td> <TD id=e > Press 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