Home » Tip Bank » Visual Basic
  • Email Article
  • Comment on this Article
  • Share Article
    • Digg
    • del.icio.us
    • Newvine
    • furl
    • StumbleUpon
    • BlinkList
    • Newsvine
    • Magnolia
    • Facebook
    • Tailrank
    • Slashdot
    • Technorati
    • Google Bookmarks
    • Yahoo Favorites
    • Windows Live
    • Ask
Language: Visual Basic Classic (6 and earlier)
Expertise: Advanced
Oct 27, 2016

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.
Oracy
 
Submit a Tip
Browse "Visual Basic" Tips
Browse All Tips
codeschool.com
html-color-codes.info