nodegui / react-nodegui

Build performant, native and cross-platform desktop applications with native React + powerful CSS like styling.🚀
https://react.nodegui.org
MIT License
6.18k stars 171 forks source link

OS key events (globalShortcut) #332

Open R-Bower opened 3 years ago

R-Bower commented 3 years ago

Is your feature request related to a problem? Please describe. The react-nodegui instance can't detect key events when the application doesn't have focus.

Describe the solution you'd like Detect keyboard events when the application does not have keyboard focus (similar to electron's globalShortcut)

Describe alternatives you've considered

a7ul commented 3 years ago

Can you see if there are any existing node module that does this already ?

a7ul commented 3 years ago

https://www.npmjs.com/package/iohook

This should do it?

R-Bower commented 3 years ago

https://www.npmjs.com/package/iohook

This should do it?

import iohook from "iohook" then, when I npm run dev

Critical dependency: the request of a dependency is an expression
 @ multi webpack/hot/poll?100 ./src/index.js

npm start fails with: Error: Cannot find module '/builds/node-v83-linux-x64/build/Release/iohook.node'

I've also tried adding iohook to the webpack config's externals, like so: externals: {iohook: "iohook"},

But this fails on npm start with

module.exports = iohook;
                 ^
ReferenceError: iohook is not defined