<p>在输入框中按下 Esc 键(左上角)会弹出提示信息。</p> <input type="text" size="50" onkeydown="myFunction(event)"> <script> function myFunction(event) { var x = event.which || event.keyCode; if (x == 27) { alert ("你按下了 Esc 键!"); } } </script>