if mdown() *Lost focus by Mouse else *Lost focus by Keyboard endifin the Lost focus, but this will alwyas return Keyboard if you click outside of the form, otherwise its accurate. To be sure, I would suggest doing this in the GotFocus() if possible, then it would always be right on.