When I check the keyCodes on the softKeyboard for .- , the e.key
in JavaScript is "Unidentified" and the e.keyCode
is 229 for all of those characters.
The device I am using is a TC52k scanner and the scan trigger has the same key and keyCode... so it can't be completely disabled.
I don't know how many things I tried that didn't work... but I will post some...
This is a dynamic field bound with rivets.js using JSON objects
$(document).on("keydown", ".qty-input", function(e) {
let code = e.keyCode;
if (code == 229 && $(this).val().charAt(str.length - 1) == ".") {
$(this).val($(this).val().slice(0, -1));
}
});
^Basically, that says that if the last character has the code 229 and the last character of the entered string is a '.', then cut the last character off... but doesn't work correctly.
I also did this that basically says to only accept keys that have keycodes between 48 and 57 which are keys 1-9 on the android soft keyboard.
<input class="qty-input" placeholder="0" type="number" min="0" step="1" onkeypress="return event.charCode >= 48 && event.charCode <= 57 && event.keyCode != 229" pattern="[0-9]*" autofocus>
Also didn't work...
Does anyone have experience with this and can help? I know there's lots of unsolved posts about this online. It's the last thing I have to do and its keeping my app from being deployed!
Also... I've tried these function using events: keyup, keydown, change, input and keypress...