Re: JavaScript, Detecting KeyUp or KeyDown KeyCode

  • From: "RicksPlace" <ofbgmail@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 22 Jul 2009 13:21:30 -0400

Hi Jim, good idea. I will use it. I was using the onkeyup but the onchange will 
be more accurate and not trigger execution of the JS for non input keys. A 
second JS will pop up a message if the TextBox is clicked with the mouse 
telling the character count and the max allowed or the remaining character 
count before exceeding the max or something. A label will display the 
information to sighted folks in real time while a screen reader user will have 
to click the TextBox to get the numbers but that is not much of a hassle. 
Finally, I will pop up a message to a screen reader user automatically if they 
exceed the max.
I like your idea though, it will eliminate a problem I was having when the 
textbox was full. The message would pop up but trying to hit delete would 
trigger the onkeyUp or down and not allow the user to remove excess characters. 
Your idea should take care of that one.
I'll give that puppy a try!
Thanks again:
Rick USA
  ----- Original Message ----- 
  From: Homme, James 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Wednesday, July 22, 2009 12:42 PM
  Subject: RE: JavaScript, Detecting KeyUp or KeyDown KeyCode


  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: