static L<NativeKeyAdapter> onGlobalKeyRelease_listeners = synchroList();

// f: voidfunc(NativeKeyEvent)
static AutoCloseable onGlobalKeyRelease(fO f) {
  jnativehook_init();
  final NativeKeyAdapter listener = new {
    @Override
    public void nativeKeyReleased(NativeKeyEvent e) {
      pcallF(f, e);
    }
  };
  GlobalScreen.addNativeKeyListener(addAndReturn(onGlobalKeyRelease_listeners, listener));
  ret autoCloseable { GlobalScreen.removeNativeKeyListener(listener); };
}

static void cleanMeUp_onGlobalKeyRelease() {
  for (NativeKeyAdapter a : getAndClearList(onGlobalKeyRelease_listeners))
    GlobalScreen.removeNativeKeyListener(a);
}