Unitech / Unitech/pm2

iohook cannot working

Open
#4,835 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

I use pm2 in my local nodejs program, not a website application. The usage scenario is: when the user presses the keyboard shortcut (enter), my program will take a screenshot of the specified area of the screen. When I use node app.js to start the program, user key press events can be captured normally, but when I use pm2 start app.js, user key press events cannot be monitored. I use the ioHook package as a user key press event capture tool. How can I improve my program? I use pm2 on windows system.

How could we reproduce this issue?

Just start this script in pm2

const iohook = require('iohook')
function ioListener() {
  iohook.on('keydown', (e) => {
    if (e.keycode === 28) {
      console.log('enter was pressed')
    }
  })
}
ioListener()

Supporting information

# Save the code in app.js above
pm2 start app.js

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduced app.js script and compare node app.js with pm2 start app.js on Windows. Investigate how PM2 launches the process and how the iohook keyboard listener behaves in that context. Done means identifying a reproducible cause and documenting or implementing a PM2-compatible fix for keydown capture.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.