iohook
iohook copied to clipboard
[OSX high sierra] Key- press/down/up is only called once
Expected Behavior
Upon attaching key- press/down/up, the callback should be fired every time these events happen.
Current Behavior
The callback is only fired once
Possible Solution
No clue
Steps to Reproduce (for bugs)
const iohook = require('iohook');
iohook.on('keydown', event => {
console.log(event);
});
iohook.start();
Your Environment
NodeJS: 10.11.0
I can confirm this with node v8.11.4 (no electron)
Hi there !
Thanks for your feedback. I can't reproduce this on Mojave. Will try a bit more tomorrow or later this week when I can.
@Djiit Thanks! Good to know it's working on Mojave at least, it's probably time to update then. Before I do though, is there anything I can help you with regarding testing on High Sierra? I can place some console logs in the lib and share the results if that helps.
I'm using only mouse events, but whenever I press a keyboard key, mouse events stop firing. I'm using MacOS High Sierra too.
me too(in mojave 10.14.1).
my log
$ cat index.js
const iohook = require("iohook")
iohook.on("keydown", e => {
console.log("down", e)
})
iohook.on("keyup", e => {
console.log("up", e)
})
iohook.start(true)
$ node index.js
hook_run [1121]: Accessibility API is enabled.
hook_run [1172]: CGEventTapCreate Successful.
hook_run [1178]: CFMachPortCreateRunLoopSource successful.
hook_run [1183]: CFRunLoopGetCurrent successful.
hook_run [1196]: CFRunLoopObserverCreate successful.
dispatch_event [108]: Dispatching event type 1.
hook_enable [257]: Thread Result: (0).
process_mouse_moved [882]: Mouse moved to 725, 495.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 726, 495.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 728, 496.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 729, 497.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 730, 497.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 730, 497.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 730, 497.
dispatch_event [108]: Dispatching event type 9.
process_mouse_moved [882]: Mouse moved to 731, 497.
dispatch_event [108]: Dispatching event type 9.
process_key_pressed [367]: Key 0X1E pressed. (0)
dispatch_event [108]: Dispatching event type 4.
process_key_pressed [379]: Using dispatch_sync_f for key typed events.
down { shiftKey: false,
altKey: false,
ctrlKey: false,
metaKey: false,
keycode: 30,
rawcode: 0,
type: 'keydown' }
^C
$ node -v
v8.12.0
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.1
BuildVersion: 18B75
is it fixed?
I can't reproduce this; and I'm on Mojave.
I just ran into this issue on a fresh project identical to the example provided and I'm using Mojave.
Just running in a raw node app, no electron involved. Node v10.10.0
Running in debug mode and found out that it removes all callbacks. I was getting mouse events firing until a key was pressed. So I think this is a problem in the NodeHookAddon
.
Does line 89 need a break;
? I'm only vaguely familiar with any of the C languages. But if the key is not the escape key, this switch would fall through to the key release case, right?
https://github.com/wilix-team/iohook/blob/8233c8af806b0c811267a6515adfa06d41edd6a7/libuiohook/src/demo_hook.c#L67-L89
Hi, i have same issue. After first keydown event callbacks stop calling.
I'm on Mojave 10.14.2
, node version 10.15.0
.
const ioHook = require('iohook');
ioHook.start(true);
Here is debug output
hook_run [1121]: Accessibility API is enabled.
hook_run [1172]: CGEventTapCreate Successful.
hook_run [1178]: CFMachPortCreateRunLoopSource successful.
hook_run [1183]: CFRunLoopGetCurrent successful.
hook_run [1196]: CFRunLoopObserverCreate successful.
dispatch_event [108]: Dispatching event type 1.
hook_enable [257]: Thread Result: (0).
process_key_pressed [367]: Key 0X39 pressed. (0X31)
dispatch_event [108]: Dispatching event type 4.
process_key_pressed [379]: Using dispatch_sync_f for key typed events.
^C
I commented out this line and rebuilt the package.
I don't familiar with C, and don't know what this line does, but now all works fine.
I hoping this may be helpful
Hi guys,
These file are part of libuiohook, the lib used by iohook. I suggest you open an issue there.
Le jeu. 3 janv. 2019 à 18:27, Oleg Kravchenko [email protected] a écrit :
Hi, i have same issue. After first keydown event callbacks stop calling.
I'm on Mojave 10.14.2, node version 10.15.0.
const ioHook = require('iohook');
ioHook.start(true);
Here is debug output
hook_run [1121]: Accessibility API is enabled. hook_run [1172]: CGEventTapCreate Successful. hook_run [1178]: CFMachPortCreateRunLoopSource successful. hook_run [1183]: CFRunLoopGetCurrent successful. hook_run [1196]: CFRunLoopObserverCreate successful. dispatch_event [108]: Dispatching event type 1. hook_enable [257]: Thread Result: (0). process_key_pressed [367]: Key 0X39 pressed. (0X31) dispatch_event [108]: Dispatching event type 4. process_key_pressed [379]: Using dispatch_sync_f for key typed events. ^C
I commented out this line https://github.com/wilix-team/iohook/blob/master/libuiohook/src/darwin/input_hook.c#L380 and rebuilt the package.
I don't familiar with C, and don't know what this line does, but now all works fine.
I hoping this may be helpful
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wilix-team/iohook/issues/124#issuecomment-451215897, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHZtKo8fbN0NGzFcUVHI4qMogCji2hUks5u_j2NgaJpZM4YVO8m .
I also have this problem.
I followed LastDreamer's advice and commented-out the offending line. Everything now seems to be working.
Hi, i have same issue. After first keydown event callbacks stop calling.
I'm on Mojave
10.14.2
, node version10.15.0
.const ioHook = require('iohook'); ioHook.start(true);
Here is debug output
hook_run [1121]: Accessibility API is enabled. hook_run [1172]: CGEventTapCreate Successful. hook_run [1178]: CFMachPortCreateRunLoopSource successful. hook_run [1183]: CFRunLoopGetCurrent successful. hook_run [1196]: CFRunLoopObserverCreate successful. dispatch_event [108]: Dispatching event type 1. hook_enable [257]: Thread Result: (0). process_key_pressed [367]: Key 0X39 pressed. (0X31) dispatch_event [108]: Dispatching event type 4. process_key_pressed [379]: Using dispatch_sync_f for key typed events. ^C
I commented out this line and rebuilt the package.
I don't familiar with C, and don't know what this line does, but now all works fine.
I hoping this may be helpful
Can you tell me the detail steps to rebuild this? I comment out this line, and try to rebuild it. But I fail to do this. Thanks a lot !:>
Also having this issue on Mac OS X 10.14.
@LastDreamer - Can you provide your steps?
@Djiit https://github.com/kwhat/libuiohook/issues/2 looks like they were having the issue, but then solved it
Perhaps this was a different issue though
If it isn't, maybe this module has an outdated version of their code?
@MulverineX - That thread is from 2014, I doubt iohook's dependency is that old.
@Djiit - Can you weight in on this?
Hi there !
I can confirm we use libuiohook v1.1 so yes, we have this fix
@Djiit - I'm using 'latest: 0.4.0' for iohook, and this 'fires-once' bug still persists on macOS Mojave. Do you have any recommendations? I would very much like to use this package.
https://github.com/wilix-team/iohook/issues/124#issuecomment-450697095 this comment of any help/work?
Just to confirm. Same problem on Mojave here
Same problem on Mojave here +1
on Mojave +1
I can confirm this is still an issue (high sierra)
Same here 🖐
Still have the problem there after a keydown mousemove stop his callback ! Some info :
I also have this problem, node 10.16.0 and mojaveOS 10.14.1
Hi! I tried the solution explained in this comment https://github.com/wilix-team/iohook/issues/124#issuecomment-451215897 and it works! Thanks @LastDreamer
Not sure when this is going to be fixed but for now our team feels forced to make a fork of iohook until this is fixed, this bug is huge, it makes the library unusable in macOS.
See the steps to fix the library here:
- Clone iohook repository
git clone https://github.com/wilix-team/iohook.git iohook
- Execute in terminal
cd iohook
- Comment this line
Now you need to compile the library
- The library used to compile iohook is cmake-js so for example, if you want to build the library for NodeJS v10.16.0 (My case)
You need to execute this:
npx cmake-js compile -r node -v 10.16.0
BTW is useful to use the --help command to see the options ofcmake-js
like thisnpx cmake-js compile --help
After the compilation is completed look for the file build/Release/iohook.node
, this is your compiled library, now you need to move it to your project. Look in <your_real_project>/node_modules/iohook/builds/
here you need to find the folder according to your platform and node version. For me, the folder name is node-v64-darwin-x64
. The v64 is the ABI of the nodeJS version. If you want to find this folder more easily, in the documentation you can find a small script: https://wilix-team.github.io/iohook/manual-build.html
Just copy the script from the docs and run node script.js
. The script will tell you the right name folder according to the node version you use to execute the script.
In few words, copy the repo, comment the line, rebuild, copy the compiled library to your real project in the real project and that's it.
Hope this helps you.