static L onGlobalKeyPress_listeners = synchroList(); // f: voidfunc(NativeKeyEvent) static AutoCloseable onGlobalKeyPress(fO f) { jnativehook_init(); final new NativeKeyAdapter listener; GlobalScreen.addNativeKeyListener(addAndReturn(onGlobalKeyPress_listeners, listener = new NativeKeyAdapter { public void nativeKeyPressed(NativeKeyEvent e) { pcallF(f, e); } })); ret autoCloseable { GlobalScreen.removeNativeKeyListener(listener); }; } static void cleanMeUp_onGlobalKeyPress() { for (NativeKeyAdapter a : getAndClearList(onGlobalKeyPress_listeners)) GlobalScreen.removeNativeKeyListener(a); }