📄 onkeydown.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>onkeydown Event Sample</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<META NAME="AUTHOR" CONTENT="InetSDK">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<SCRIPT>
function fnTrapKD(){
if(oTrap.checked){
oOutput.innerText+="[trap = " + event.keyCode + "]";
event.returnValue=false;
}
else{
oOutput.innerText+=String.fromCharCode(event.keyCode);
}
}
</SCRIPT>
</HEAD>
<!-- SAMPLE_STYLE_START -->
<LINK REL="stylesheet" HREF="../../../../../workshop/basicsdkie4.css"
TYPE="text/css">
<!-- SAMPLE_STYLE_END -->
<BODY>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<BLOCKQUOTE>
<H1>onkeydown Sample</h1>
<P>This sample demonstrates the implementation of the <b>onkeydown</b> event. As of Internet Explorer 5, most keys that fire the <b>onkeydown</b> event are cancelable.</P>
<P>Type some text into the <LABEL FOR=oExample>Example Text</LABEL> field.
If the <LABEL FOR=oTrap>Cancel onkeydown Event</LABEL> check box is checked, the key strokes do not show up in the text field, and "[trap]" is displayed in the <b>TEXTAREA</b> element. If the check box is not checked, the key strokes are displayed in both the text field and the <b>TEXTAREA</b> element.</P>
<FIELDSET>
<LEGEND>onkeydown Sample</LEGEND>
<P><LABEL FOR=oTrap>Cancel onkeydown Event:</LABEL> <INPUT TYPE=checkbox ID=oTrap></P>
<LABEL FOR=oExample>Example Text:</LABEL> <INPUT ID=oExample TYPE=TEXT onkeydown="fnTrapKD();alert(oExample.value);">
<P>
<TEXTAREA ID=oOutput ROWS=10 COLS=50>
</TEXTAREA>
</FIELDSET>
</BLOCKQUOTE>
<!-- START_PAGE_FOOTER -->
<!-- END_PAGE_FOOTER -->
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -