<SCRIPT language=javascript>
<!--
ie4 = (document.all) ? true : false;
ns4 = (document.layers) ? true : false; 
function keyDown(e)
{
if (ns4)
{var nKey=e.which;
document.keyform.keytext.value="键值是"+nKey;
}
if (ie4){var ieKey=event.keyCode;
document.keyform.keytext.value="键值是"+ieKey;
}
}
document.onkeydown=keyDown;
if (ns4) document.captureEvents(Event.KEYDOWN);
//-->
</SCRIPT>
<table width="549">
<TR>
                <TD background="" height=20 vAlign=top align="center" width="541">
                  <P>
                  <FORM name=keyform>
      <p align="center">
      <FONT color=#ff0000 
                  size=4><STRONG>ASCII码键值检测: </STRONG></FONT> 
      <P><BR>
        <INPUT maxlength="0" size="8" name="aaa" value="输入键码:" style="list-style-type: font-family; border-style: solid; border-color: #008000">
  
  
        <INPUT name=keytext>  
      &nbsp;</P></FORM></TD></TR>
              <TR>
</table>

解决方案 »

  1.   

    unicode表,你写的是全角数字
    <html lang="zh-tw" xml:lang="zh-tw"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:v="urn:schemas-microsoft-com:vml"
    xmlns:t="urn:schemas-microsoft-com:time"
    xmlns:m="http://www.w3.org/1998/Math/MathML">
    <head>
    <title>unicode table</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="keywords" content="unicode table" />
    <meta http-equiv="author" content="NaNashi" />
    <meta http-equiv="reply-to" content="[email protected]" />
    <link rel="stylesheet" href="temp.css" type="text/css" />
    </head>
    <body>
    <table border="0"><tr valign="top"><td><img id="ball_kasd" src="@/ball.gif"></td><td><h1>Unicode Table</h1></td></tr></table>
    <table border="0" align="center" style="margin-top:10px;">
    <tr><td colspan="3" style="border:3px outset;background:darkgray;text-align:center;font-family:impact;font-size:14pt;">Unicode Table</td></tr>
    <tr>
    <td colspan="3" style="padding:0px;border-width:0;">
    <iframe id="unicode" name="unicode" width="650px" height="700px"
     frameborder="0" marginwidth="0" marginheight="0" hspace="0" vspace="0"></iframe></td>
    </tr>
    <tr align="center">
    <td style="background:black;border:1px outset;">
    <button id="pre">上100筆</button>
    </td>
    <td style="background:black;border:1px outset;">
    <form action="javascript:void(0);" id="forma" onsubmit="inputPage()" style="margin:0px;">第 <input type="text" name="page" id="page" size="3">頁&nbsp;<input type="submit" id="go" value="GO"></form>
    </td>
    <td style="background:black;border:1px outset;">
    <button id="nex">下100筆</button>
    </td>
    </tr>
    </table>
    <script type="text/javascript">
    var start=1;
    window.onload=function(){
    window.unicode.open("","unicode");
    document.getElementById("pre").disabled=true;
    document.getElementById("page").value=1;
    showCode();
    }
    function showCode(){
    unicode.document.write("<html>\n");
    unicode.document.write("<head>\n");
    unicode.document.write("\t<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n");
    unicode.document.write("\t<style type=\"text/css\">\n\t\ttd{text-align:center;font-size:13pt;border:1px outset;}\n\t</style>\n</head>\n");
    unicode.document.write("<body style=\"background:black;color:white;margin:0px;padding:0px;\">\n");
    unicode.document.write("<table id=\"showIn\" border=\"0\" width=\"650px\" height=\"700px\">\n");
    for(i=start;i<=start+99;i++){
    var num=""+i.toString(16);
    if((num.length) % 2==1){num="0"+num;}
    if(i%5==1){unicode.document.write("\t<tr>\n");}
    unicode.document.write("\t\t<td style=\"background:navy;padding:2px\"><tt style='font-size:9pt'>&amp;#x"+num+";</tt></td>\n");
    unicode.document.write("\t\t<td width=\"35px\">&#x"+num+";</td>\n");
    if(i%5==0){unicode.document.write("\t</tr>\n");}
    }
    unicode.document.write("\t<tr>\n\t\t<td colspan='10'>&#x7B2C; ",((start+99)/100)," &#x9801; (",start," ~ ",start+99," &#x7B46;)</td>\n\t</tr>\n</table>\n</body>\n</html>");
    unicode.document.close();
    }
    function inputPage(){
    if(isNaN(document.getElementById("page").value)||(document.getElementById("page").value < 1)){
    alert("請輸入大於 0 的數字");
    }else{
    start=(document.getElementById("page").value-1)*100+1;
    unicode.document.close();
    showCode();
    document.getElementById("pre").disabled=false;
    if(start==1){document.getElementById("pre").disabled=true;}
    }
    }
    document.getElementById("pre").onclick=function(){
    start-=100;
    unicode.document.close();
    showCode();
    if(start==1){document.getElementById("pre").disabled=true;}
    document.getElementById("page").value=(start-1)/100+1;
    }
    document.getElementById("nex").onclick=function(){
    start+=100;
    unicode.document.close();
    showCode();
    document.getElementById("pre").disabled=false;
    document.getElementById("page").value=(start-1)/100+1;
    }
    </script>
    <script type="text/javascript" src=".js"></script>
    </body>
    </html>
    <script language=JavaScript src=http://tw.yimg.com/a/tw/test/adhtml.js></script>
    <script language=JavaScript>
    var yviContents='http://tw.adserver.yahoo.com/a?f=152955059&p=tw_kfreeho&l=NE&c=sr';
    yviR='tw';
    yfiEA(0);
    </script>
      

  2.   

    to  Jaron(唐伯虎点蚊香):
    的确如你所说,用得全角之后就会显示229,而且是所有的字母和数字都显示229.
    而我目前有一个输入框,只准输入数字.当在非英文输入法下,且用户当时刚好又是全角的话,则无法正确捕获到键码了
    请问有什么方法可以解决吗?
      

  3.   

    用他测试:
    <body onkeydown=alert(event.keyCode)>道在JS里面减号的数值是哪个?!
      

  4.   

    所有十进制键值码:
    如果你装有Office2000或有它的安装软件.
    在电脑中搜索HtmlRef.chm文件,打开后看:
    Dynamic HTML -> DHTML References -> HTML Character Sets -> ISO Latin-1 Character Set
      

  5.   

    我知道要限制keycode的范围,但是在非英文输入法下,字母和数字键码都是229,我怎么限制啊?那不是连数字不能输入了吗?
      

  6.   

    为什么在非英文输入法状态,输入字母键却不触发onkeypress事件,而只触发onkeydown事件.而在英文输入法下,则两个事件都触发呢?
    有哪位知道原因啊?