How to detect global keystrokes?

Is there a way to detect keystrokes when the sketch window is not active?
I would like to read each keyPressed event even if another application has focus and the sketch is in background.

I found this on StackOverflow, maybe that helps?

lemme checkā€¦
This is great, but how to import it as a library?