When searching for ways to allow only numbers on a text input you usually get something like:
function keyPressEvent (e) {
var keyCode = e.which || e.keyCode;
if (keyCode < 48 || keyCode > 57) {
return false;
}
}
But the problem is that this makes keys that only do commands not work. Starting with backspace and delete, but even ctrl+a or f5. I know I can create exceptions for all of this, but I think this will be a waste of time. Is there some easy way to do what I want? Is there something like detecting the character that will be added to the text, and not the key pressed?