How to check if a property is writable?

M

mav

To stop the keyboard event for the F4-key from propagating in IE I need
to set event.keyCode to 0. But setting keyCode to 0 in Mozilla/Firefox
will throw an exception since it is a read-only property.

So, how do I check if event.keyCode is writable?

(I could do some check to see if the script is run in IE or add a
try/catch for Mozilla, but I would like to know the 'correct' method)

Thanks, MAV
 
R

Randy Webb

mav said the following on 1/17/2006 7:18 AM:
To stop the keyboard event for the F4-key from propagating in IE I need
to set event.keyCode to 0. But setting keyCode to 0 in Mozilla/Firefox
will throw an exception since it is a read-only property.
So, how do I check if event.keyCode is writable?

You don't. You cancel propogation and return false from the onkey* event
handler.
 
M

mav

I completely agree, but this doesn't work for certain keys (e.g. F4).
AFAIK the only way to cancel the F4 key in IE is to set keyCode to 0.
 
R

Randy Webb

mav said the following on 1/17/2006 8:01 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
I completely agree, but this doesn't work for certain keys (e.g. F4).
AFAIK the only way to cancel the F4 key in IE is to set keyCode to 0.

Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).
 
M

mav

Randy Webb schreef:
Why are you trying to redefine my keyboard?
F4 in IE shows me my Address Bar drop-down.
F4 in Mozilla does nothing for me.
So I don't see where trying to cancel F4 does any good unless it does
something different that I am not seeing (I opened both and hit F4 to
see what the key does).

Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).
So I need to catch the F4-key in the (on)keydown, submit the form and
cancel the default action.
 
R

RobG

mav said:
Randy Webb schreef:




Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).
So I need to catch the F4-key in the (on)keydown, submit the form and
cancel the default action.

Since there Mozilla doesn't appear to have default action defined for
the F4 key, there's nothing to cancel. ;-)


There's a discussion here that may help:

<URL:
http://groups.google.com/group/comp...d?q=show+keycode&rnum=5&#doc_972df56c39040975
 
R

Randy Webb

mav said the following on 1/17/2006 8:52 AM:
Randy Webb schreef:




Our customer specifically requested the use of the F4 key to submit
pages (to make the transition from the legacy application easier).

Maybe you need to educate your customer on the futility of it then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top