If you're asking for help troubleshooting this issue, you'll want to provide a lot more detail, such as:
- which MacBook Pro?
- which macOS version is it running?
- which external display are you connecting to?
- what type of connection is it?
- does this happen in a specific app? If so, which one? If it happens in multiple apps, list a few of them
- when did the problem start?
- are you using the MBP keyboard or an external keyboard?
You get the idea.