How to show NSPopover without dismissing the first responder?

I'm working on a mac app that has similar functionalities to the Rocket macOS app.

Whenever the user types : outside of my app I'll show an NSPopover with NSTableView near the cursor. The problem I'm facing here is that The moment I show the NSPopover it becomes the first responder and the user couldn't continue typing.

So I tried this, Showed the NSPopover without making a first responder, and used NSEvent.addGlobalMonitorForEvents(matching: .keyDown, handler: ) to listen UpArrow, DownArrow and Enter actions to navigate and select results. The downside of this approach: Let's say I'm composing a new mail, and the cursor responding to the up/down arrow events, eventually moved to other lines.

Attaching gifs for reference,

The functionality that I'm expecting

From my app

Note: Notice the cursor position to understand what goes wrong.

How to show NSPopover without dismissing the first responder?
 
 
Q