W3Schools 在线编辑工具(TIY) V3.0
编辑的代码:
运行代码 »
©
w3s.com.cn
运行结果窗口大小:
300 x 150
<
html
>
<
head
>
<
script
type
="text/javascript"
>
function
whichButton(event)
{
alert(event.keyCode)
}
<
/script
>
<
/head
>
<
body
onkeyup
="whichButton(event)"
>
<
p
>
<
b
>
注释:
<
/b
>
在测试这个例子时,要确保右侧的框架获得了焦点。
<
/p
>
<
p
>
在键盘上按一个键。消息框会提示出该按键的 unicode。
<
/p
>
<
/body
>
<
/html
>
<html> <head> <script type="text/javascript"> function whichButton(event) { alert(event.keyCode) } </script> </head> <body onkeyup="whichButton(event)"> <p><b>注释:</b>在测试这个例子时,要确保右侧的框架获得了焦点。</p> <p>在键盘上按一个键。消息框会提示出该按键的 unicode。</p> </body> </html>