akzhan / jquery-keyfilter

This plugin filters keyboard input by specified regular expression.
http://akzhan.github.com/jquery-keyfilter/
37 stars 11 forks source link

Firefox: mask-int not blocking all characters #16

Closed melloware closed 1 year ago

melloware commented 5 years ago

See: https://github.com/primefaces/primefaces/issues/5110

Using Firefox with the following input

 <input type="text" class="mask-int" />

Hold <shift> and hack down keys 0 to 9, some (not all) of which will add their punctuation to the inputs below.

The issue is because you swithced to JQuery on("keypress") it automatically filters out non-printable characters: https://api.jquery.com/keypress/

This is similar to the keydown event, except that modifier and non-printing keys such as Shift, Esc, and delete trigger keydown events but not keypress events. Other differences between the two events may arise depending on platform and browser.

I have fixed it by removing this code as its no longer needed. https://github.com/akzhan/jquery-keyfilter/blob/bed2c03c95af64f4e6c79bfa8079e762b14887a1/jquery.keyfilter.js#L139-L142

You can also remove this code as its no longer being used as well: https://github.com/akzhan/jquery-keyfilter/blob/bed2c03c95af64f4e6c79bfa8079e762b14887a1/jquery.keyfilter.js#L96-L101