event.ctrlKey

L

Loony

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?
 
S

Stephen Chalmers

Loony said:
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;
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top