| Author |
ALT Key Combination help.
|
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 206
|
|
Hello Ranchers , I have come across a situation where in i have a textbox with me and i want to use a combination of ALT + P as a shortcut to printout a customized receipt. I wrote a sample javascript code which captures the keycode for ALT and i wanted to test if javascript is able to detect that i pressed ALT key , I succeeded in it. I made a small textbox and on its onKeyDown event , i gave a alert saying ALT is Pressed. This is half part , now i want to also include the P part in it , i mean ALT + P , if this combination is used i want to redirect the user to a page saying successfully forwarded. Can you javascript freaks help me with this ? Thanks in advance. Yogendra N Joshi.
|
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Look into modifier keys: event.altKey Eric
|
 |
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 206
|
|
hi Eric , thanks for the response but i have already been able to get ALT keypress event trapped.. What i want is , how i can use the combination of ALT + P , how do i add this + P to ALT and then let the user go on the success page. Please let me know..
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
The modifier key can be detected with the other keys. You do not look for the keyCode of 18 You are looing for the keyCode of 80 with the modifier key event.altKey Eric
|
 |
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 206
|
|
So you mean to say something like this : I tried with the above code but i guess there is something wrong in the if block which i have coded , right now the flow goes to else with the above code.. Also using javascript how can i forward to a html page ? Please answer both my queries.. Thanks.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Well you code is not cross browser friendly: I only tested this on Firefox 1.5 on Linux, should be fine on IE. Eric
|
 |
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 206
|
|
Hey Eric , Thanks, You rock. It worked for me. Yogendra N Joshi.
|
 |
 |
|
|
subject: ALT Key Combination help.
|
|
|