I thought the same, and was surprised to find the problem here seems to be that there's no part of the HTML spec to set the allowable characters in a text input.
So JavaScript to intercept keypresses or postprocess the string is risky at best and often poorly implemented.
If it was in HTML it could be reliable, and have a unified behaviour when text is pasted in.
For phone numbers there is a "tel" input, so the undesirable behaviour your experiencing may be in spite or because of it.