Monitor mouse and key board events

I am trying to track mouse events in RemObject c#, for OSX Application. For this I tried the solution below but it does not work. Can you tell me how is it work

public override void windowDidLoad()
			NSEvent.addGlobalMonitorForEventsMatchingMask(NSEvent.EventTypeMask.KeyDown) handler(eventMonitorHandler);

		private void eventMonitorHandler(NSEvent e)

Hmm, this looks correct, but i can’t get it to work, either

however if I change the event type to Any, I do get MouseMoved (and only MouseMoved) events… this seems to be something that’s broken on OS level, not specific to Elements, as I see many questions about this on Google, and no solutions.

            NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.Any) handler(( @event) => {
                Log($"pressed! {@event}");

Hi, as you mentioned in your reply that might be this OS level issue therefore I have no way but to test it in swift. I have written a small program for macos which useses the NSEvent.addGlobalMonitorForEvents and I was able to capture all the events.

So, my question is that why it is not working in Elements. (37.9 KB)

Strange. I coped your exact code over to Elements (attached), and I see only mouse events, yet I can confirm in the Xcode version I see keyboard events too…

MacApp4 (512.0 KB)

~> Process MacApp4 started, took 0.155.
2022-09-29 11:13:38.971889-0400 MacApp4[95227:9250855] global event monitor: 1
mouse event raised
2022-09-29 11:13:39.098117-0400 MacApp4[95227:9250855] global event monitor: 2
mouse event raised
2022-09-29 11:13:39.106421-0400 MacApp4[95227:9250855] global event monitor: 3
mouse event raised
2022-09-29 11:13:39.114607-0400 MacApp4[95227:9250855] global event monitor: 4
mouse event raised

if I print out the value of mask, its 5164 (0x142C) in both versions. I really don’t get what the difference could be, sorry :(.

Does this mean that we can not use/consume MacOS keyboard events from Elements at all?

One more question: Can this be the issue related to MacOS security?

Best Regards,

It could be, but I don’t see how/why, if it works in Xcode. Let me double-check if the Xcode project had any entitlements or anything else special set, by default (it shouldn’t).

Oddly, the Xcode project is set to run sandboxed (which should be, if anything, more restricted). But worth trying the same in the Elements one


Nothing else stands out; the project is “signed to run locally” only; same as Elements does (required on arm Macs to run anything).

Oddly, now (not sure if that’s only because I added the entitlements, I do get “keyboard flags events”. but still no “key down” ones :(. I also get others with type “1”, “4” and “22” (left mouse down, right mouse down, and scrollwheel)

Nope, not related to the entitlements at all.

This is really baffling.