Nick, Stefan, and Rob:
Thank you all for the comments and suggestions. My users (unknown to me)
will probably have an IE browser (probably 6/7/8 for now), with perhaps a
few having a different/better browser (I have most of the current browsers
on my dev machine, but my stuff *must* still work on IE6 and better)
It would be more useful to say what behaviour you are trying to
modify, rather than simply asking to disable the key.
In my real app I have approx 72 single-char (usually digit) input text
fields.
When the user inputs a (say) digit, there are several operations I have
to carry out (totalling, modifying, etc, etc other fields).
I have to be prepared for my users making mistakes, and allowing them
(and controlling them) in the usage of <Backspace>,<Tab>, <Delete>, <Esc>,
etc, etc.
I kow what I *want* to happen when a user presses a particular key, and
can (mostly) control my JS response to the key.
I have onfocus, onblur, and onkeyup JS functions active for all my
fields. The onfocus and onblur control background color, and the onkeyup
function should get all keys from the user, and act on them appropriately.
*However*, the <Esc> input from IE puzzles me:
On Focus, the mouse pointer shows as a vertical in *front* of the
single digit, but with the following onkeyup event, it appears in the same
field but *after* the single digit -- with the digit still remaining in the
field. *But* apparently the onblur event is called after the second press
You can't disable the key using javascript code running in a browser,
however you may be able to prevent particular default responses to its
being pressed in some circumstances. It all depends on the browser and
behaviour as different browsers do different things in different
circumstances in response to varouis key presses.
My problem is the way IE7 treats the various keys in my JS 'onkeyup'
function. Some keys modify the field *before* my onkeyup is activated, some
don't do anything, and the rest I haven't determined yet.
But, so far, it is the operation of two sequential <Esc> key inputs in
the same field that blows me away.
(It may be that the onblur event occurs after the *second* <Esc> input
on a specific field. I'll have to investigate this later today)
If the issue is related to modifying user behaviour, you may be better
off teaching them different usage patterns than trying to modify the
browser UI.
I won't even know where or who my users are until I get this app
going. So, there's minimum I'll be able to modify their behaviour
(
What I don't want is the user to feel frustrated when entering these
70-odd input fields. He/She will never return if I demand perfection.
Thank for all your comments !
-Mel Smith