plentz / jquery-maskmoney

jQuery plugin to mask data entry in the input text in the form of money (currency).
https://plentz.github.io/jquery-maskmoney/
MIT License
962 stars 506 forks source link

Signal handling is incorrect on android #279

Open sparcbr opened 2 months ago

sparcbr commented 2 months ago

The minus key on android does not fire on key press event. So I used this code on key down event:

if ($.browser.device && key == 229) { // minus key on android
  var val = e.target.value;
  if ((val.match(/-/g) || []).length >= 1) {
      val = val.replaceAll("-", ""); //remove signal
  } else {
      if (settings.allowNegative) {
          val = '-' + val; //add signal
      }
  }
  setTimeout(function() { // need this because we can't use preventDefault on android
      $input.val(val);
  }, 100);

  return false;
}
sparcbr commented 2 months ago

Doesn't work on some samsung phones . The code is always 229 from the keypad on key down event :(