First, just a correction in your first sentence:
I couldn't find my keys and asked my friend where they were. (Because "couldn't" is in the past tense.)
It might sound even better (to a native-speaker) to say:
I couldn't find my keys, so I asked my friend where they were.
And, in this context, in your last sentence, I would say "the same thing," not "the same." "The same thing" is more idiomatic.
Now, to answer your question...
I thought the same thing.
This definitely doesn't sound right to me as a native speaker. It sounds like the events followed this timeline:
You realized you lost your keys.
You thought they were in your trousers.
You stopped thinking they were in your trousers.
You friend suggests they might be in your trousers.
I was thinking the same thing.
This is the response I would use. This has the following timeline:
You realized you lost your keys.
You begin thinking they might be in your trousers. And then your friend says...
Your friend suggests they might be in your trousers.
I have been thinking the same thing.
This response might be appropriate. It implies that you've been thinking for a relatively long time that your keys are in your trousers.
You realized you lost your keys.
You think they might be in your trousers.
Some time passes, and you continue to think they might be in your trousers, so you ask you friend, and he says...
Your friend suggests your keys might be in your trousers.
I have thought the same thing.
This sounds very peculiar. This would mean:
A long time ago, before you ever lost your keys, you have had the thought that your keys might be in your trousers (like, you're psychic or something haha).
You realize you lost your keys.
You ask your friend, and he says they might be in your trousers.