Filtering user input is extremely mundane. Who never captured user’s keystrokes in a TextBox in order to avoid some forbidden input, such as numbers or letters?
If you went down this rabbit hole, here are some things to keep in mind:
- User can hit navigational keys like Left Arrow, Right Arrow, Home, End, or Tab. They are perfectly valid keys in a TextBox.
- Remember to allow selection combinations keys like Shift + Home, Shift + End, Shift + Left Arrow, and Shift + Right Arrow as well.
- Del and Back Space should never be filtered out.
- You should probably allow Ctrl + C and Ctrl + X combinations, but maybe restrict Ctrl + V.
- If you restricted Ctrl + V, you should think what to do when user right-clicks the TextBox and select Paste in the contextual menu that appears.
- If your TextBox has an associated Help context ID, you should allow the F1 key.