I\'m interested in seeing if it\'s possible to bind functions to a user pressing/releasing a key on the keyboard.
So far, I\'ve been able to get key press events wit
That is a good tool: https://www.npmjs.com/package/iohook
Look at the sample code:
npm install iohook
const ioHook = require('iohook');
/* In next example we register CTRL+F7 shortcut (in MacOS, for other OS, keycodes can be some different). */
const id = ioHook.registerShortcut([29, 65], (keys) => {
console.log('Shortcut called with keys:', keys)
});
ioHook.on("keydown", event => {
console.log(event);
/* You get object like this
{
shiftKey: true,
altKey: true,
ctrlKey: false,
metaKey: false
keycode: 46,
rawcode: 8,
type: 'keydown'
}
*/
});
//register and start hook
ioHook.start();
// Alternatively, pass true to start in DEBUG mode.
ioHook.start(true);
Link of usage of package ioHook doc https://wilix-team.github.io/iohook/usage.html