fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p>在输入框中输入键盘上的字母获取按下字母的 Unicode 字母代码和 Unicode 键代码 。</p> <p><strong>注意:</strong> which 和 keyCode 属性不能用于onkeypress的非打印事件,功能键 (如 CAPS LOCK, CTRL, ESC, F12, 等)。</p> <input type="text" size="50" onkeypress="uniCharCode(event)" onkeydown="uniKeyCode(event)"> <p>onkeypress - <span id="demo"></span></p> <p>onkeydown - <span id="demo2"></span></p> <script> function uniCharCode(event) { var char = event.which || event.keyCode; document.getElementById("demo").innerHTML = " Unicode 字符代码为: " + char; } function uniKeyCode(event) { var key = event.keyCode; document.getElementById("demo2").innerHTML = " Unicode 键代码为: " + key; } </script> </body> </html>
运行结果