链接类

VML

按钮类

标题类

表单类

表格类

菜单类

窗口类

对象类

滚动条

键盘类

框架类

例子类

模拟类

日期类

色彩类

鼠标类

数学类

图片类

文字类

下拉框

样式类

游戏类

状态栏

资料类

字幕类

其它类

 ·软键盘
 ·屏蔽鼠标右键、Ctr...
 ·键盘的keyCode
 ·模拟键盘
 ·键盘代码
您当前位置:好素材首页 -> 网页特效 -> 键盘类
查看信息

onkeydown与onkeypress的区别
好素材网 www.HaoSc.com 02月22日 11:49

[查看演示]  源码如下
----------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="Author" CONTENT="haiwa">
<META NAME="Keywords" CONTENT="51windows.Net">
<title>onkeydown与onkeypress的区别-www.51windows.Net</title>
<style>
body,p{font-size:11px;font-family:Verdana;font-weight:normal;}
</style>
</head>
<body bgcolor="#FFFFFF">
<p><B>onkeypress</B><br>
As of Microsoft&amp;reg; Internet Explorer 4.0, the onkeypress event fires and can be canceled for the following keys:<br>
<br>
Letters: A - Z (uppercase and lowercase)<br>
Numerals: 0 - 9<br>
Symbols: ! @ # $ % ^ &amp; * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~<br>
System: ESC, SPACEBAR, ENTER<br>
<br>
<br>
<B>onkeydown</B><br>
As of Microsoft&amp;reg; Internet Explorer 4.0, the onkeydown event fires for the following keys:<br>
<br>
Editing: DELETE, INSERT<br>
Function: F1 - F12<br>
Letters: A - Z (uppercase and lowercase)<br>
Navigation: HOME, END, LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW<br>
Numerals: 0 - 9<br>
Symbols: ! @ # $ % ^ &amp; * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~<br>
System: ESC, SPACEBAR, SHIFT, TAB<br>
<br>
As of Internet Explorer 5, the event also fires for the following keys:<br>
<br>
Editing: BACKSPACE<br>
Navigation: PAGE UP, PAGE DOWN<br>
System: SHIFT+TAB<br>
<br>
As of Internet Explorer 5, this event can be canceled for the following keys and key combinations by specifying event.returnValue=false:<br>
<br>
Editing: BACKSPACE, DELETE<br>
Letters: A - Z (uppercase and lowercase)<br>
Navigation: PAGE UP, PAGE DOWN, END, HOME, LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW<br>
Numerals: 0 - 9<br>
Symbols: ! @ # $ % ^ &amp; * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~<br>
System: SPACEBAR, ESC, TAB, SHIFT+TAB<br>
<br>
You can cancel all keys that fire the onkeydown event in HTML Applications, including most accelerator keys, such as ALT+F4.<br>
<br>
In Internet Explorer 4.0, you cannot cancel the onkeydown event, but you can use the onkeypress event to cancel keyboard events.<br>
<br>
两个一起按,可以这样:<br>
<br>
if( window.event.shiftKey &amp;&amp; event.keyCode==xx)<br>
</p>
<BODY>
</BODY>
</HTML>


<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="Button" value="查看源代码" onClick= 'window.location = "view-source:" + window.location.href'></div>


此信息共 1 页 [1]