复制代码 代码如下: <BR> function jumpPage() { <BR> if (event.keyCode==37)//左 <BR>fun_a(); <BR>if (event.keyCode==38)//上<BR> fun_b();<BR> if (event.keyCode==39)//右 <BR>fun_c(); <BR>if (event.keyCode==40)//下 <BR>fun_d();<BR> } <P><BR> <P>function fun_a(){ <BR>window.alert('你按下了左')<BR> } <P>function fun_b(){ <BR>window.alert('你按下了上')<BR>} <P>function fun_c(){ <BR>window.alert('你按下了右') <BR>} <P>function fun_d(){<BR> window.alert('你按下了下') <BR>} <BR>document.onkeydown=jumpPage; <P> HTML code 复制代码 代码如下: 按向下键 按向下键 按向下键 按向下键 按向上键 按向上键 按向上键 按向上键 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 = ""; } }