I found out the following.
In the appDelegate class, I created the variable
statusItem with
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
in the method
func applicationDidFinishLaunching(_ notification: Notification)
I have setup the statusItem with entries.
Now that I have only added the variable
statusItem with:
var statusItem: NSStatusItem?
and only declared it in the method
func applicationDidFinishLaunching(_ notification: Notification)
with
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
there are no more problems with the keyboard responder and its events.
Maybe it helps one or the other.