<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>KeyDown</title>
    <script type="text/javascript">
        window.document.onkeydown = fun;
        function fun(evt) {
            evt = (evt) ? evt : window.event
       evt.preventDefault();
            if (evt.keyCode) {
                document.getElementById('inpcode').value = evt.keyCode
                document.getElementById('inpval').value = String.fromCharCode(evt.keyCode)
            }
        }
    </script>
</head>
<body>
    <div>
        <input type="text" id="inpcode" />
        <input type="text" id="inpval" />
    </div>
</body>
</html>

 

相关文章:

  • 2021-12-02
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案