devxlogo

Something to Remember When Filtering Keystrokes

Something to Remember When Filtering Keystrokes

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:

  1. User can hit navigational keys like Left Arrow, Right Arrow, Home, End, or Tab. They are perfectly valid keys in a TextBox.
  2. Remember to allow selection combinations keys like Shift + Home, Shift + End, Shift + Left Arrow, and Shift + Right Arrow as well.
  3. Del and Back Space should never be filtered out.
  4. You should probably allow Ctrl + C and Ctrl + X combinations, but maybe restrict Ctrl + V.
  5. 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.
  6. If your TextBox has an associated Help context ID, you should allow the F1 key.
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist