W
W
Wasya UK2021-04-26 21:57:10
Node.js
Wasya UK, 2021-04-26 21:57:10

Why is the key not being pressed in robotjs?

I try to hold down the key for a few seconds, look at the documentation, and everything seems to work, but as a result I get only 1 button press without holding. What could be the problem?

const robot = require('robotjs');

function start(st, end) {
  setTimeout(() => {
    st();
  }, 5000);
  setTimeout(() => {
    end();
  }, 15000)
}

start(
  () => {
    robot.keyToggle("w", "down");
  },
  () => {
    robot.keyToggle("w", "up");
  }
);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question