I am bringing a popup when F2 button is pressed but the problem is when I press Q button the popup is coming. My first thought was its the problem with my keyboard, so I tried in different system, the result was same. Then I made a test code, just to ensure there is no bug in my code, but it also gives same result. This is my sample code
<html>
 <head>
  <script>
   function giveFocusToRespectiveQuantity(evt) {
       var charCode = (evt.which) ? evt.which : evt.keyCode;
       alert(charCode);
   }
  </script>
 </head>
 <body>
  <input type="text" onkeypress="return giveFocusToRespectiveQuantity(event)">
 </body>
</html>
As you can see when F2 and Q are pressed the charcode is same for both. Why is that?
These links say that key code for Q is 81
                        
use 'onkeydown' or 'onkeyup' instead. because onkeypress only detects allowed keys, not control keys.
for example:
returns 113 for F2 and 81 FOR q/Q keys.