JavaScript Keyboard Function
- 3 sene önce, Burak Çalışkan tarafından yazılmıştır.
- JavaScript Keyboard Function için yorumlar kapalı
- Genel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<html> <head> <title>Untitled</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <style type="text/css"> td,th{border:2px solid #aaa;} </style> <script type="text/javascript"> var t_cel,tc_ln; if(document.addEventListener){ //code for Moz document.addEventListener("keydown",keyCapt,false); document.addEventListener("keyup",keyCapt,false); document.addEventListener("keypress",keyCapt,false); }else{ document.attachEvent("onkeydown",keyCapt); //code for IE document.attachEvent("onkeyup",keyCapt); document.attachEvent("onkeypress",keyCapt); } function keyCapt(e){ if(typeof window.event!="undefined"){ e=window.event;//code for IE } if(e.type=="keydown"){ t_cel[0].innerHTML=e.keyCode; t_cel[3].innerHTML=e.charCode; }else if(e.type=="keyup"){ t_cel[1].innerHTML=e.keyCode; t_cel[4].innerHTML=e.charCode; }else if(e.type=="keypress"){ t_cel[2].innerHTML=e.keyCode; t_cel[5].innerHTML=e.charCode; } if (e.keyCode==113){ alert("F2 basildi.kaydet"); } } window.onload=function(){ t_cel=document.getElementById("tblOne").getElementsByTagName("td"); tc_ln=t_cel.length; } </script> </head> <body> <table id="tblOne"> <tr> <th style="border:none;"></th><th>onkeydown</th><th>onkeyup</th><th>onkeypress</td> </tr> <tr> <th>keyCode</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td> </tr> <tr> <th>charCode</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td> </tr> </table> <button onclick="for(i=0;i<tc_ln;i++){t_cel[i].innerHTML='&nbsp;'};">CLEAR</button> </body> </html> |