Robotjs: keyToggle doesn't repeat key on 'down', or release on 'up' (Windows 10)

Created on 1 Aug 2017  路  2Comments  路  Source: octalmage/robotjs

When I run keyToggle('w, 'down') it only taps the button once in text editors/chrome.

For example, my code:

robot.keyToggle('w', 'down'); setTimeout(function(){ robot.keyToggle('w', 'up'); }, 2000);

Only results in one 'w' character being entered in notepad or chrome.

However, if I run the code then switch to a game (Portal 2) it acts like it's holding it down and runs the character forwards, but the key stays down indefinitely (keyToggle up does nothing) and character keeps running forward.

So the functionality of this just seems like it's not working as expected for some reason. Note this was tested with the game running and without it running (just in the desktop using notepad/chrome URL bar).

Steps to Reproduce (for bugs)

Code:

var robot = require('robotjs');

robot.setKeyboardDelay(500);

function testWASD() {
  console.log('testing');
  toggleKey('w', 'down');

  setTimeout(function(){
    toggleKey('w', 'up');
  }, 2000);
}

function toggleKey(key, direction) {
  console.log('key:', key, ' direction:', direction);
  robot.keyToggle(key, direction);
}

setTimeout(testWASD, 1000);

Your Environment

  • RobotJS version: "^0.4.7"
  • Node.js version: v6.11.1
  • npm version: 5.3.0
  • Operating System: Windows 10 Pro 64-bit

EDIT: SOLUTION

Found out this was the same solution as found here https://github.com/octalmage/robotjs/issues/252

Most helpful comment

The same thing is occuring to me with minecraft. I am just pressing and releasing the "w" key to move forward and it doesn't release it. The character just keeps walking forward. I deleted the lines in keypress.c but nothing changed.

All 2 comments

Required rebuilding the project with some lines commented out as in this issue:

https://github.com/octalmage/robotjs/issues/252

The same thing is occuring to me with minecraft. I am just pressing and releasing the "w" key to move forward and it doesn't release it. The character just keeps walking forward. I deleted the lines in keypress.c but nothing changed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MariaDima picture MariaDima  路  3Comments

Glutch picture Glutch  路  6Comments

piyushpatil027 picture piyushpatil027  路  3Comments

quinton-ashley picture quinton-ashley  路  6Comments

saghul picture saghul  路  6Comments