2

I'm trying to determine whether or not a user left the WPF TextBox using the keyboard or the mouse.

If I decide to monitor the TextBox for certain keys being pressed, what are the keys for which I should watch? Put another way (hence the question title):

Question: With what keys can a user possibly leave a WPF TextBox?

Is it only Tab , or are there other keys to consider?

Community
  • 1
  • 1
lance
  • 16,092
  • 19
  • 77
  • 136

2 Answers2

2

Don't forget about

  • Shift-tab
  • Arrow keys (depending on focus)
  • Alt menu option key combinations

  • Alt-tab

  • Windows key
CodingBarfield
  • 3,392
  • 2
  • 27
  • 54
  • shift-tab for sure. Most of the rest would take focus away from the app, which wouldn't fire a losing/got focus event in the app, I don't think. I'm not sure about the arrow keys, though. In what case would the arrow keys cause the focus to change? What am I missing? – Jeff Walker Jun 15 '11 at 14:55
0

tab by default. However, In windows forms (including WPF) you have full control over everything so the keystrokes/keystroke combinations that could cause a control to lose focus is virtually limitless. It would probably be fairly easy to see if anything specific could cause a specific control to lose focus, but covering all possibilities is impractical in the general case.

Also, have you considered how to handle voice recognition software that lets a user navigate a screen?

Ethan Cabiac
  • 4,943
  • 20
  • 36
  • The voice recognition concern might be appropriate for someone with a wider user scope than mine. – lance Jun 14 '11 at 15:06