首页javascriptkeyJavascript Event - 如何句柄键按下事件

Javascript Event - 如何句柄键按下事件

我们想知道如何句柄键按下事件。


<html>
<head>
    <script language="JavaScript1.2">
    function showDialog(type){
      console.log("An onKey" + type + " event just occurred");
    }
    </script>
</head>
<body>
    <form name="myForm">
       <textarea name="myTextArea" rows=2 cols=50
                onKeyDown='showDialog("Down")'
                onKeyPress='showDialog("Press")'>
       Here is some text in my text area.
       </textarea>
    </form>
</body>
</html>