This is a part of Node3D project.
npm install @node-3d/iohookNode.js addon providing a hook to track global input and shortcuts. This work is derived from wilix-team/iohook.
import { iohook } from '@node-3d/iohook';
iohook.on('keydown', (event) => {
console.log(event.keycode);
});
iohook.shortcut([29, 65], (keys) => {
console.log('Shortcut pressed with keys:', keys);
});
if (!iohook.init()) {
throw new Error('Global input permission is unavailable');
}
iohook.start();Importing the package does not start global input capture. Call init() first;
it returns false when the current process cannot capture input (including when
macOS Accessibility or Input Monitoring permission is unavailable). start()
throws if initialization was skipped or the operating system denies access.
stop() is safe to call when the hook is not running.
Note: this addon uses N-API, and therefore is ABI-compatible across different Node.js versions. Addon binaries are precompiled and there is no compilation step during the
npm installcommand.
Release archives are built by this repository's public GitHub Actions workflows.
Attestations: https://github.com/node-3d/iohook/attestations
To verify a downloaded archive:
gh release download <tag> -R node-3d/iohook -p <platform>.gz
gh attestation verify <platform>.gz -R node-3d/iohook