Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried this code but only Left (Alt + P) is working,
I have to run Right (Alt + P) also.
Right (Alt + P)
is not working.
Please help me.

What I have tried:

$(document).keydown(function (event) {
				if (event.altKey && event.which === 80) {
					//My code.
					event.preventDefault();
				}
			}
Posted
Updated 28-Mar-23 22:14pm
v2
Comments
OriginalGriff 28-Mar-23 8:22am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

Use the "Improve question" widget to edit your question and provide better information.

Try this to see if you right alt-key works.

Here's a JSBIN you can run to see the key, keycode and if alt key is pressed.

JS Bin - Collaborative JavaScript Debugging[^]
 
Share this answer
 
v2
Comments
Agarwal1984 29-Mar-23 0:05am    
When i type left alt + P so condition is true but when i type right side alt key so its condition is false.
I did not resolve my issue, i want to run same functionality left or right alt key type with P.
Actually problem with combination with P or any alphabet key.
raddevus 29-Mar-23 10:17am    
If you tried my example and it still didn't work then either:
1. it is your browser -- which browser are you using?
2. it is your keyboard

Good luck,
Agarwal1984 31-Mar-23 2:04am    
Google Chrome Browser.
yes It is my keyboard.
raddevus 31-Mar-23 8:19am    
ok, well sorry to hear about your keyboard problem, but at least you were able to discover what the root cause was. Thanks for posting back and mentioning that you found the problem. Good luck to you.
Agarwal1984 3-Apr-23 0:57am    
not my keyboard problem, problem with only combination with P, single alt working fine but with combination not working.
This problem in every system I have tried many system or keyboard.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900