By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,775 Members | 1,306 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,775 IT Pros & Developers. It's quick & easy.

Catch Ctrl+Alt+<letter>

P: n/a
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?
--
Regards,
Paul
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Paul Gorodyansky wrote:
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

Jul 23 '05 #2

P: n/a
Janwillem Borleffs wrote:

Paul Gorodyansky wrote:
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.


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)

--
Regards,
Paul
Jul 23 '05 #3

P: n/a
Paul Gorodyansky wrote:
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

Jul 23 '05 #4

P: n/a
Janwillem Borleffs wrote:

Paul Gorodyansky wrote:
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


Hi,

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

Thanks,
Paul
Jul 23 '05 #5

P: n/a
Anyone?
--
Regards
Paul
Jul 23 '05 #6

P: n/a
Paul wrote:
Anyone?


Yes.
PointedEars
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.