Copiez le code comme suit :
<script type="text/javascript">
fonction jumpPage() {
si (event.keyCode==37)//gauche
fun_a();
if (event.keyCode==38)//Up
fun_b();
if (event.keyCode==39)//droit
fun_c();
if (event.keyCode==40)//Suivant
fonds();
}
fonction fun_a(){
window.alert('Vous avez appuyé à gauche')
}
fonction fun_b(){
window.alert('Vous avez appuyé')
}
fonction fun_c(){
window.alert('Vous avez appuyé sur la droite')
}
fonction fun_d(){
window.alert('Vous avez appuyé dessus')
}
document.onkeydown=jumpPage;
</script>
Code HTML
Copiez le code comme suit :
<table cellpacing="1" cellpadding="0" id=table> <tr id="lineone" style="background-color:#00cccc;"> <td id=aa></td> <td id=aa >Appuyez sur la touche enfoncée</td> <td id=cc >Appuyez sur la touche enfoncée</td> <td id=dd >Appuyez sur la touche enfoncée</td> <td id=ee >Appuyez sur la touche enfoncée</td > </tr> <tr id="linetwo" tyle="background-color:#ffffff;"> <td id=a></td> <td id=b >Appuyez sur la touche haut</td> <td id = c >Appuyez sur la touche haut</td> <td id=d >Appuyez sur la touche haut</td> <td id=e >Appuyez sur la touche haut</td> </tr></table><langage de script ="javascript" > fonction keyDown(e) { var iekey=event.keyCode; action(iekey); } document.onkeydown = keyDown; function action(iekey) { if(iekey==40) { lineone.style.backgroundColor = ""; .backgroundColor = "#00cccc"; } if(iekey==38) { lineone.style.backgroundColor = "#00cccc"; linetwo.style.backgroundColor = ""; } } </script><input name="id" type="hidden" id="id" valeur