首页javascriptkeyJavascript Event - 如何跟踪密钥代码

Javascript Event - 如何跟踪密钥代码

我们想知道如何跟踪密钥代码。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>

</head>
<body>
  <div>Click here!!!</div>
    <script type='text/javascript'>
    
    var myArr = [];
    document.addEventListener('keypress', function(e) {
        var newContent = myArr.push(e.keyCode);
        console.log(myArr);
    });
    
    </script>
</body>
</html>