Keypress Function is Not Working in Firefox ? Here’s An Alternate.

If you have come googling for this article. Then you obviously understand what the keypress function is, and all about how it works. At first, you would have been very happy when you realized that such a function exists, but now it has become irritating for you that it lacks browser compatibility.

Ahh! There is no need to worry. There is a very simple solution to it and you won’t even have to change your code for it.

The Alternative is the Keydown or Keyup function. The Keydown event is activated, when the key is pressed, and the keyup is activated when the key is released. So, depending on your need replace keypress in your code by keydown or keyup. Nothing else is to be changed.

{code type=javascript}
$(document).keydown( function() {
//Do Something Here
}); //end keydown

The Two Keyup and Keydown functions, when combined result in a keypress operation. But let’s not curse firefox for being unable to support it and move ahead.

If you need more details, on how keypress functions work in jQuery, read the following: Keypress Functions in Jquery. The implementation of Keypress, Keydown & Keyup is same in jQuery.

Leave a Reply

Your email address will not be published. Required fields are marked *