iPad's hardware keyboard shortcut with multiple instances

Hi! I am trying to implement keyboard shortcuts via overriding keyCommands on a custom UIHostingController. But there is a problem where when multiple instances of my app is viewed side by side on iPad, the same keyboard shortcuts are triggered in both instances.

In Apple's native apps, only the last interacted instance have the keyboard shortcuts implemented. Where should and how this logic can be implemented?