iohook is a global native keyboard and mouse listener for Node.js. This is a fork of https://github.com/wilix-team/iohook, which is abandoned and unmainntained.
Robolab (MechaKeys, the integrated typing environment) provide a modern CI pipeline for easy, fast, reliable, builds of iohook for modern versions of Node and Electron.
Notice! This fork aim to support newer versions of Node.js / Electron and ES Module. Windows and Linux works, macOS doesn't work properly(mouse OK, keyboard NG). Therefore, I do not provide prebuilt versions for macOS. hwanyong/iohook-macos is recommended for macOS.
- Versions 1.1.7 support Electron 29-39 and Node 20-24 (Excluding Electron 32 due to c++ error)
- As of right now, i do not build 32-bit versions.
- For older version support, use the wilix-team / robolab-io library
- electron ABI versions
# Install iohook via npm
npm install --save @tkomde/iohookBy default, prebuilds will be downloaded for your own platform and architecture, but you can download specific ones through your package.json:
"iohook": {
"targets": [
"node-137",
"electron-140"
],
"platforms": [
"win32",
"linux"
],
"arches": [
"x64",
"arm64"
]
}const iohook = require('@tkomde/iohook');
iohook.on('keydown', event => {
console.log(event);
});
iohook.start();import { iohook } from '@tkomde/iohook';
# import iohook from '@tkomde/iohook'; # on bundler
iohook.on('mousedown', e => console.log(e));
iohook.start();Both import styles provide the same singleton instance.