iohook: Can't use iohook on a simple node app
Expected Behavior
Make it run on a simple node app.
Current Behavior
Showing this message and closing porcess:
refresh_locale_list [476]: GetKeyboardLayoutList(0, NULL) found 3 layouts.
refresh_locale_list [493]: Received 3 locales.
load_input_helper [866]: refresh_locale_list() found 3 locale(s).
Steps to Reproduce (for bugs)
- Use node 15.x
- Run npm install iohook --save
- node run index.js
- Use node 10.x
- Do step 2
- Do step 3
index.js:
const ioHook = require('iohook')
ioHook.on('keydown', key => {
console.log(key)
})
ioHook.start(true);
Context
I’m trying to run a simple node application but it shows that message and closes the process. I changed the node version to 10.9.0 and reinstalled the module, and nothing happens.
[EDIT]: When run as a test script, it shows that the test failed. But you don’t see an error message.
Your Environment
- Version used: ^0.7.2
- Environment name and version (e.g. Chrome 39, node.js 5.4): node 15.4.0, node 10.9.0
- Operating System and version (desktop or mobile): Windows 10 pro 2004 x64 - desktop
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 7
- Comments: 45 (10 by maintainers)
@denyncrawford I was able to get this functional on node v14 by using v0.6.6 of the library. It seems that versions past that (0.7.x) are broken.
Update: looks like it’s working fine in all Node versions <= 13.x but fails silently in >= 14.x. Appears to be a Windows Node 14+ only issue.
@Djiit Erm I haven’t fixed the issue? I only ‘fixed’ the code example supplied by @denyncrawford. I.E. They used
key => code
and incorrect capitalisationioHook = ... --> iohook.on --> ioHook.start
.The code sample still doesn’t actually do anything apart from log the 3 messages stated. But the initial code sample had no hope of working either.
I’m getting this as well with exactly the same output. It should be noted that all that is required to duplicate this issue is to require(‘iohook’);
@TheMrGong thank you os much! 0.6.6 works with node 14
@miro-ux this thread is about an issue using iohook in just-plain-Node not Electron. Since you’re using Electron, latest iohook 0.9.3 works fine in Electron 12 on Windows. iohook 0.6.6 predates Electron 12 so there is no older 0.6.6 prebuild targeting Electron 12.
Haha, you’re right, but that’s not the problem. I probably copied the mixed code from the two tests I was doing. I proceed to edit, thank you.
ok i think i see the problem you are trying to build from the files that come down the pipe when you
npm install iohook
but that doesn’t include the full iohook source. What you need to do is clone the iohook git repo. Thennpm install
from the root of your local copy of the repo… thennpm run build
Completely missed that one. Thank you
@bomeers I followed the instructions from the documenation