Skip to content

Numpad buttons don't work on Linux #360

Closed
@suchipi

Description

@suchipi

Version
2.0.0

Short overview
Calling keyboard.pressKey(nut.Key.NumPad1) doesn't work on Linux. It doesn't seem to work for any numpad key.

Issue occurs on

  • Virtual machine
  • Docker container
  • Dev/Host system

Detailed error description

If you run the following code in Node.js 12.22.7 on Linux Mint 20.3 Cinnamon 20.3,

const nut = require("@nut-tree/nut-js");

nut.keyboard.pressKey(nut.Key.NumPad1);

the result of the last line will be rejected with this error:

Error: Invalid key code specified.
    at /wherever/node_modules/@nut-tree/nut-js/dist/lib/provider/native/libnut-keyboard.class.js:22:28

Steps to reproduce error

  • Install Linux Mint Cinnamon 20.3
  • Install Node.js 12.22.7.
  • Create a file named test.js with the following content:
    const nut = require("@nut-tree/nut-js");
    
    nut.keyboard.pressKey(nut.Key.NumPad1);
  • Open a terminal emulator and use cd to navigate to the folder where said script (test.js) resides.
  • Type in node ./test.js

Expected behavior:

Numpad 1 gets pressed (virtually), so a "1" is typed into the terminal.

Actual behavior:

The key is not pressed, no "1" is typed into the terminal, and the following error is printed:

Error: Invalid key code specified.
    at /wherever/node_modules/@nut-tree/nut-js/dist/lib/provider/native/libnut-keyboard.class.js:22:28

Additional content

Please provide any (mandatory) additional data to reproduce the error (Dockerfiles etc.)

I am using a US keyboard layout, and my keyboard has a numpad. I also have a mouse attached that presents itself as both a mouse and a keyboard (because it has some macro keys on the side).

I am using Xorg, not wayland.

I have two monitors attached to my computer, and the primary monitor is on the right of the secondary monitor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhancement to existing featureslibnutRoot cause located in libnut

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions