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