<script> document.onkeydown = function(event){ let e = event || window.event || arguments.callee.caller.arguments[0] if(e && e.keyCode == 27){ // 按Esc console.log(e.keyCode); } } </script>