470,573 Members | 1,801 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

event.ctrlKey

I want to use a ctrlKey event in my script!
I have a code like this:

function hiLite(imgDocID, imgObjName) {
document.images[imgDocID].src = eval(imgObjName + ".src")
}

function KeyDown() {
Key1=event.ctrlKey //JavaScript shows this event is not defined
Key=event.keyCode
if ((String.fromCharCode(Key)=="q") && (Key1))
{
if ( self.document.newContract.do_DKT.checked==true )
{
self.document.newContrac.do_DKT.checked=false
hiLite('cha_r','bom2')
document.images["cha_r"].value=0
}
else
{
self.document.newContrac.do_DKT.checked=true
hiLite('cha_r','bom1')
document.images["cha_r"].value=1
}
}
and my Firefox Javascript console says that event: event.ctrlKey is not
defined, but MS IE works right!
The script is placed in my file not imported from any other source!
What should I do?

Aug 2 '05 #1
1 9102
Loony <lo*****@op.pl> wrote in message news:11**********************@g43g2000cwa.googlegr oups.com...
I want to use a ctrlKey event in my script!
I have a code like this:

function hiLite(imgDocID, imgObjName) {
document.images[imgDocID].src = eval(imgObjName + ".src")
}

function KeyDown() {
Key1=event.ctrlKey file://JavaScript shows this event is not defined
Key=event.keyCode
if ((String.fromCharCode(Key)=="q") && (Key1))
{
if ( self.document.newContract.do_DKT.checked==true )
{
self.document.newContrac.do_DKT.checked=false
hiLite('cha_r','bom2')
document.images["cha_r"].value=0
}
else
{
self.document.newContrac.do_DKT.checked=true
hiLite('cha_r','bom1')
document.images["cha_r"].value=1
}
}
and my Firefox Javascript console says that event: event.ctrlKey is not
defined, but MS IE works right!
The script is placed in my file not imported from any other source!
What should I do?


This:

<SCRIPT type='text/javascript'>

function readCtrlKey(e)
{
if(typeof(e)=='undefined')
e=window.event||window.Event;

if ( (typeof(e.ctrlKey)!='undefined' && e.ctrlKey) || ( e.modifiers & Event.CONTROL_MASK) )
/* Whatever you do when Ctrl is pressed */
}

}

if(window.Event && document.captureEvents)
document.captureEvents(Event.KEYDOWN);
document.onkeydown=readCtrlKey;
--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A

Aug 2 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Andy Read | last post: by
2 posts views Thread by znndrp | last post: by
4 posts views Thread by phil_gg04 | last post: by
9 posts views Thread by jeff | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.