源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function whichButton(event){ alert(event.keyCode); } </script> </head> <body onkeyup="whichButton(event)"> <p><b>注釋:</b>在測試這個例子時,要確保右側的框架獲得了焦點。</p> <p>在鍵盤上按一個鍵。消息框會提示出該按鍵的 unicode。</p> </body> </html>
運行結果