Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

event.keycode is not working in Mozilla .pl z, is there any solutions to fix this issue.
i tried with other option from Google.
like i used this below but still not working
(event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);


What I have tried:

i tried with other option from Google.
like i used this below but still not working
 <pre>(event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);
Posted
Updated 14-Jun-18 23:31pm

1 solution

See KeyboardEvent.keyCode - Web APIs | MDN[^]:
Quote:
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use KeyboardEvent.code, if it's implemented. Unfortunately, some browsers still don't have it, so you'll have to be careful to make sure you use one which is supported on all target browsers. Google Chrome and Safari have implemented KeyboardEvent.keyIdentifier, which was defined in a draft specification but not the final spec.

See also the example code at the link which checks for the availability of the various event members. I don't know why that is not checking first for the recommended KeyboardEvent.code - Web APIs | MDN[^] property which should work with recent Mozilla browsers.

But note that returned values differ for the property itself (with the code property), the used browser, and the operating system. You would have to handle all these cases. So the best solution would be to avoid using key codes at all.
 
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