Since this is a MacBook Pro, you might ask your question in that forum; this forum is for iMac users.
You might check to see if the problem still happens when you Safe Boot Mac OS X. If the problem isn't there when you Safe Boot, then it's probably related to a third-party program or startup item.
When something is handling keyboard input, we say it has "focus". When you're typing into a text field, then that field has focus. If you click somewhere else, then focus moves to where you clicked. What you're describing sounds like focus is moving somewhere unexpectedly. It might help to figure out where.
While it won't solve your problem, VoiceOver can help is figure out where focus is going. VoiceOver is a program that's part of Mac OS X that is designed to let blind users use the computer, but it also may help shed some light on your situation.
Open System Preferences, and select Universal Access. Under the "Seeing" tab, click "Open VoiceOver UtilityâŠ". In the "Navigation" section, make sure that "Initial position of VoiceOver cursor" is set to "Keyboard focused item". Also, make sure that "VoiceOver cursor follows keyboard focus" is checked. Close VoiceOver Utility and go back to System Preferences. Still in the "Seeing" tab of Universal Access, turn on VoiceOver. At this point, the computer will start talking, so use headphones if the baby's asleep!
VoiceOver will show an introductory note, and read it to you. You can just click "Ok". Now, VoiceOver will tell you whenever the focus moves. VoiceOver can be tricky in a web browser if you're not used to it, so ignore Safari for this test. Instead, start a new Mail message, or open Spotlight, or do anything else that will give you a text cursor. Wait six blinks, and listen to what VoiceOver says when the cursor disappears. It should briefly describe where the focus has moved to. For example, if focus moves to the Finder, then it may say something like "Finder, Desktop" and the name of the currently selected file. If you want more information, you can press Control-Option-F4 (you probably need to hold down Fn as well, since you're on a laptop). That will make VoiceOver describe what has keyboard focus. (Control-Option-F3 will give you a little bit different information too.)
You may want to repeat this test a few times with different programs and different windows to see if there's a pattern. For instance, if focus always moves to the same program regardless of what's open, then that program may be stealing focus. Once you've got an idea of where focus is going, you can turn off VoiceOver in System Preferences.
While this won't fix your problem, it may provide more information to make it easier to figure out what's going on.