RE: JavaScript, Detecting KeyUp or KeyDown KeyCode

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 22 Jul 2009 12:42:25 -0400

Hi Rick,
I have an idea that might work. Use the onchange event and attach it to the 
text field. In the onchange event function, get the length of the value of the 
input field and store it in some global variable or do whatever you want with 
it. The code avoids checking keys altogether, which automatically makes it 
independent of any browser unless JavaScript is turned off or something.

Jim


----------
Jim Homme
Usability Services
412-544-1810
james.homme@xxxxxxxxxxxx

"You can do anything you want to if you put your mind to it" -- Jim Homme Sr.

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of RicksPlace
Sent: Wednesday, July 22, 2009 11:13 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: JavaScript, Detecting KeyUp or KeyDown KeyCode

Hi: Well, it never ends...
In my JS routine I want to detect some special key to use as a hot key to pop 
up an alert box when pressed. Reading up on the topic it seems that various 
browsers recognize diferent keys for the same key when pressed. Has anyone used 
Key detection in a JavaScript routine that uses a key that would not normally 
be used for normal data entry? The fx keys do not generate a KeyPress but I'm 
not sure about KeyUp and KeyDown in the various browsers. Or, do you have a 
diferent idea of how to tell a user how many characters they have entered in a 
TextBox from the client-side?
A label control would require tabbing out of the TextBox and back in, not 
smooth and resetting focus to the last character typed in the TextBox might be 
tricky when tabbing back in, I'm not sure. I have everything working but now 
need some way to trigger the JS Alert box only on a user request or on 
exceeding the max length allowed for the TextBox. Any ideas?
Rick USA

________________________________
This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.

Other related posts: