473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 9295
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
1
by: Matthew | last post by:
I have this code snippet that is ignoring a Tab key and executing something(); on all other key-presses. How would I efficiently modify this to include a second key, such as backspace (KeyCode 8)?...
2
by: znndrp | last post by:
Hi all, I've got a function that captures a keypress event. This is working fine, but in some cases I want to fire the same even again but with different parameters. Example; ...
4
by: phil_gg04 | last post by:
Dear Javascript Experts, I'm currently implementing Anyterm, a terminal emulator on a web page. It consists of an Apache module, some XmlHTTP and a bit of Javascript. The idea is to give you...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
0
by: kavi2012 | last post by:
Hi I used the following function to disable the cut, Copy & paste in the Textbox. It works fine for me when I use ctrl+C,ctrl+X & ctrl+V. function disable(e) { if(event.ctrlKey) { ...
8
Jezternz
by: Jezternz | last post by:
I came across a very interesting problem recently. Basicly I am building an editor and I want to take advantage of hot keys. I got it working perfectly in Internet Explorer, But I hit problems when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.