iohook icon indicating copy to clipboard operation
iohook copied to clipboard

(feat) disable event propagation

Open WilixLead opened this issue 7 years ago • 10 comments

Need way for optional prevent event broadcasting. Something like:

iohook.on('keyup', (event) => {
  event.preventDefault();
});

Or equal method

WilixLead avatar Dec 27 '17 09:12 WilixLead

Is this possible? I've been looking for modules that has this, but found none so far.

I want to make an app to control another computer's keyboard/mouse, just like Synergy. Simulating keys/mouse on the "client" computer is not a problem, only problem is that the host key/mouse should be prevented.

sam-lex avatar Feb 05 '18 13:02 sam-lex

Need to review this feature in https://github.com/kwhat/libuiohook repository. iohook use this lib for hooking. I will be very happy if somebody make pull-request with this feature. At this moment I have no time for research and implement it. Sorry...

WilixLead avatar Feb 05 '18 15:02 WilixLead

hey @WilixLead any progress with this issue?

rotemgrim avatar Apr 03 '18 23:04 rotemgrim

Hi there!

I have worked to an implementation of this feature because I need it for enable/disable the propagation of mouse click events in my project.

@WilixLead it is not possible to implement this feature inside the callback because the event is already propagated at this moment but I have extended the API with two new methods.

 /**
 * Disable mouse click propagation.
 * The click event are captured and the event emitted but not propagated to the window.
 */
disableClickPropagation() {
   NodeHookAddon.grabMouseClick(true);
}

 /**
  * Enable mouse click propagation (option by default).
 * The click event are emitted and propagated.
 */
enableClickPropagation() {
  NodeHookAddon.grabMouseClick(false);
}`

Propagation is enabled by default.

It's work fine in windows and linux (it is hard to do it in x11 but is done :). I have no tested in Mac OS but I am really confident about the solution.

I am open to discuss for extend this feature to other events like key events.

I hope this helps!

eboukamza avatar May 08 '18 10:05 eboukamza

Hey @eboukamza ! That's great ! It would be awesome to be able to use this feature to key events. I'll update your PR soon. Thanks !

Djiit avatar May 08 '18 12:05 Djiit

@eboukamza It's amazing! Is there someone implementing the same feature for keyboard propagation?

wurikiji avatar Jul 26 '18 19:07 wurikiji

I updated codes to be able to enable/disable keyboard events. Please, refer to #102. Only tested on MacOS.

wurikiji avatar Sep 20 '18 19:09 wurikiji

Any news on this?

cactysman avatar Feb 26 '19 16:02 cactysman

I got something like this working. It's not enough to put into master (only works on Windows) but parallels how disableClickPropogation works:

https://github.com/theicfire/iohook/commit/f2e1e14c079e175cc97f314dfcf2203cc1467508

chaselambda avatar Jul 03 '19 08:07 chaselambda

@theicfire Great work, but when disabling keyboard keypress event won't work, and is just the one needed to extract the real character typed.

Llorx avatar May 06 '20 19:05 Llorx