[查看演示] 源码如下 ---------------------------------------------------------- <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&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: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~<br>
System: ESC, SPACEBAR, ENTER<br>
<br>
<br>
<B>onkeydown</B><br>
As of Microsoft&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: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~<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: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~<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 && 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> |