This is not a duplicate question. I have read lots of implementations of low level / global keyboard hooks using C# but none of them have yet provided a solution for MacOSX Visual Studio. Basically, I have a GTK2 .net MAC application. I want (the application) to detect whenever the space key is pressed, whether the application is on focus or not. I have successfully implemented a simple keyboard hook on a console app using C# (for Mac) but my console application would not detect the global keyboard events when the application is not in focus. Even when my current application is not in focus, I want it to detect it whenever the space key is pressed. How do I do this ? Here is my MainWindow.cs
using System;
using Gtk;
using System.IO.Ports;
using System.Threading;
public partial class MainWindow : Gtk.Window
{
// MySQL to fetch visitors number
//Create a MySQL connection
int visitors = 0;
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
public void DetectWhenSpaceKeyIsPressed(){
if(//space key is pressed -low level keyboard hook mac OSX){
//I send the data
}
}
}