fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p>在输入框中输入键盘上的字符获取按下字母的 Unicode 字符代码和 Unicode 键代码 。</p> <input type="text" size="40" onkeypress="myFunction(event)"> <p id="demo"></p> <script> function myFunction(event) { var x = event.charCode || event.keyCode; // 获取 Unicode 值 var y = String.fromCharCode(x); // 将值转换为字符 document.getElementById("demo").innerHTML = "数字: " + x + " = 字符: " + y; } </script> </body> </html>
运行结果