<!DOCTYPE html>
<html>
<head lang="zh-CN">
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1"/>
 <title></title>
 <style>
     .button {
         width: 200px;
         height: 200px;
         background-color: antiquewhite;
         margin: 20px;
         text-align: center;
         line-height: 200px;
     }
 </style>
</head>
<body>
 <div class="button">Button</div>
 <script>
     "use strict";
     var btn = document.querySelector('.button');
     document.addEventListener('keyup', function (event) {
         console.log(String.fromCharCode(event.keyCode));
     }, false);
     var ev = new KeyboardEvent('keyup', {
         keyCode: 65
     });
     document.dispatchEvent(ev);
 </script>
</body>
</html>

 

相关文章:

  • 2021-10-17
  • 2021-09-05
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-02-21
猜你喜欢
  • 2022-12-23
  • 2022-01-29
  • 2019-05-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案