event.keyCode

  • Thread starter Matthias Knöchlein
  • Start date
M

Matthias Knöchlein

hi !!
I have the following problem :
Is there a function or a constant value to check if a keyCode is a key kile
"Shift", "Alt" or "F1".
I would like not to use this way :

if( window.event.keyCode != 9
&& window.event.keyCode != 16
&& window.event.keyCode != 17
&& window.event.keyCode != 18
&& window.event.keyCode != 20
)

matthias
 
J

Janwillem Borleffs

Matthias Knöchlein said:
hi !!
I have the following problem :
Is there a function or a constant value to check if a keyCode is a key kile
"Shift", "Alt" or "F1".

You can use event.shiftKey and event.altKey, but the F1 key should be
captured by keyCode.

BTW, Mozilla provides a mapping for the keys, so you could do something
like:

if (evt.keyCode == evt.DOM_VK_F1)
alert('F1 is pressed');


JW
 
M

Matthias Knöchlein

Janwillem Borleffs said:
You can use event.shiftKey and event.altKey, but the F1 key should be
captured by keyCode.

BTW, Mozilla provides a mapping for the keys, so you could do something
like:

if (evt.keyCode == evt.DOM_VK_F1)
alert('F1 is pressed');


JW
Thanx, so I have to proove for every single key ?
 

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