Catch Ctrl+Alt+<letter>

P

Paul Gorodyansky

Hi,

Question about
event.altKey
event.ctrlKey
event.shiftKey


If I need to catch when a user does say Ctrl+Alt+G -
somehow event.altKey is not working, i.e.:


a) I press Shift+K and this works:


if (evt.shiftKey)
{
alert("************** Shift");
....
}

b) I press Ctrl+K and this works:

if (evt.ctrlKey)
{
alert("************* Ctrl");
.........
}

c) But when I press Ctrl+Alt+K - nothing:

if (evt.ctrlKey && evt.altKey )
{
alert("****************** CTRL+Alt");
...
}


Anyone knows why?
 
J

Janwillem Borleffs

Paul said:
c) But when I press Ctrl+Alt+K - nothing:

if (evt.ctrlKey && evt.altKey )
{
alert("****************** CTRL+Alt");
...
}


Anyone knows why?

Be shure to attach it to an onkeydown event.


JW
 
P

Paul Gorodyansky

Janwillem said:
Be shure to attach it to an onkeydown event.

It is attached to onkeypress event. Does it matter?

I wrote a code based on the example by Martin Honnen -
http://www.faqts.com/knowledge_base/view.phtml/aid/1661

So I have
<textarea ... onkeypress='return changeKey(this, event, fName)'>

and in that changeKey() function I am trying to use
Ctrl+Alt+letter thing

Again, I can catch event.ctrlKey and event.shiftKey but not

event.altkey
and not
(event.ctrlKey && event.altkey)
 
J

Janwillem Borleffs

Paul said:
It is attached to onkeypress event. Does it matter?

Yes it does, attach it to the onkeydown event as I said before.
Again, I can catch event.ctrlKey and event.shiftKey but not

event.altkey

It's not "event.altkey" but "event.altKey".


JW
 
P

Paul Gorodyansky

Janwillem said:
Yes it does, attach it to the onkeydown event as I said before.


It's not "event.altkey" but "event.altKey".

JW

Hi,

I was a typo _here_, not in the code - in the code it's correct

Thanks,
Paul
 

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
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top