iohook
iohook copied to clipboard
(feat) disable event propagation
Need way for optional prevent event broadcasting. Something like:
iohook.on('keyup', (event) => {
event.preventDefault();
});
Or equal method
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.
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...
hey @WilixLead any progress with this issue?
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!
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 !
@eboukamza It's amazing! Is there someone implementing the same feature for keyboard propagation?
I updated codes to be able to enable/disable keyboard events. Please, refer to #102. Only tested on MacOS.
Any news on this?
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
@theicfire Great work, but when disabling keyboard keypress
event won't work, and is just the one needed to extract the real character typed.