Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: window.event.keyCode values


Message #1 by "Ian Doak" <ian.doak@e...> on Wed, 29 Aug 2001 10:51:35
As of Microsoft® Internet Explorer 4.0, the onkeypress event fires and can 
be canceled for the following keys:

Letters: A - Z (uppercase and lowercase)
Numerals: 0 - 9
Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
System: ESC, SPACEBAR, ENTER

As of Microsoft® Internet Explorer 4.0, the onkeydown event fires for the 
following keys:

Editing: DELETE, INSERT
Function: F1 - F12
Letters: A - Z (uppercase and lowercase)
Navigation: HOME, END, LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW
Numerals: 0 - 9
Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
System: ESC, SPACEBAR, SHIFT, TAB

As of Internet Explorer 5, the event also fires for the following keys:

Editing: BACKSPACE
Navigation: PAGE UP, PAGE DOWN
System: SHIFT+TAB

As of Internet Explorer 5, this event can be canceled for the following keys 
and key combinations by specifying event.returnValue=false:

Editing: BACKSPACE, DELETE
Letters: A - Z (uppercase and lowercase)
Navigation: PAGE UP, PAGE DOWN, END, HOME, LEFT ARROW, RIGHT ARROW, UP 
ARROW, DOWN ARROW
Numerals: 0 - 9
Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
System: SPACEBAR, ESC, TAB, SHIFT+TAB

<html>

<script LANGUAGE="JScript">
function document::onkeydown()
{
  alert(event.keyCode);
  window.event.returnValue = false;
  return;
}
</script>

</head>

<body>
Press a key!

</body>
</html>

I made it 8.

Regards

Joe Fawcett



>From: "Ian Doak" <ian.doak@e...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] window.event.keyCode values
>Date: Wed, 29 Aug 2001 10:51:35
>
>Does anyone know where I could find a complete list of the values returned
>by the "window.event.keyCode" command.
>
>I am trying to test for the case when the backspace key is used to clear
>the contents of a field. I have created some simple code to display the
>key-value in an alert window on the "onKeyPress" event, however the
>backspace key does not trigger this code and therefore I can't display the
>key-value.
>
>Any help would be appreciated.
>
>Thanks in advance
>
>Ian

  Return to Index