title: Implement a global hotkey in golang?
body: <p>Let's say someone wants to create a cross-platform (Mac, Linux, Windows) global hotkey in Go (golang) - you press a hotkey combination anywhere in OS and let's say something is printed in terminal. </p>
  
  <p>Currently, (July 2016) I haven't found any library to do that, so maybe we can find a way together.</p>
  
  <p>It would involve, of course, calls to some native OS bindings for each OS, but there is very sparse information on how to do it.</p>
  
  <h1>Mac</h1>
  
  <p>Judging from Googling one should use <code>addGlobalMonitorForEventsMatchingMask</code></p>
  
  <p>EDIT: useless example removed</p>
  
  <h1>Linux</h1>
  
  <p>Looks like the suspect is <code>XGrabKey</code>, though, no example code anywhere in near sight <a href="https://github.com/search?utf8=%E2%9C%93&amp;q=language%3Ago+XGrabKey&amp;type=Repositories&amp;ref=searchresults" rel="noreferrer">https://github.com/search?utf8=%E2%9C%93&amp;q=language%3Ago+XGrabKey&amp;type=Repositories&amp;ref=searchresults</a></p>
  
  <h1>Windows</h1>
  
  <p>It seems that we need to use <code>RegisterHotKey</code>, but trying to find some example code leads nowhere: <a href="https://github.com/search?utf8=%E2%9C%93&amp;q=language%3Ago+RegisterHotKey" rel="noreferrer">https://github.com/search?utf8=%E2%9C%93&amp;q=language%3Ago+RegisterHotKey</a></p>
  
  <p>Some interesting cross-platform project to research (in Java) is <a href="https://github.com/tulskiy/jkeymaster" rel="noreferrer">https://github.com/tulskiy/jkeymaster</a></p>
  
  <p>Any help would be greatly appreciated!</p>