Skip to content

library is not working with more than 2 keyboards #6

@philippschwemberger

Description

@philippschwemberger

Hi!

Thank you for this great library.
It is exactly what I need for a project where i have to listen to and be able to distinguish between 4 different keyboard inputs.

I tried it on ubuntu 16.04 and on raspberry pi 3.
Everything works fine with 2 keyboards attached, but unfortunately I get some very strange behaviour when I attach a third one.

I use this slightly modified example code inside of the example folder

const InputEvent = require('../')

let inputSlots = [21, 23]
let inputs = []
let readers = []

for (let i = 0; i < inputSlots.length; i++) {
  try {
    inputs[i] = new InputEvent(`/dev/input/event${inputSlots[i]}`)
    readers[i] = new InputEvent.Keyboard(inputs[i])
    readers[i].on('keyup', (data) => { console.log(`reader ${i}: ${data.code}`) })
  } catch (err) {
    console.error(`Can not open device ${i}`)
  }
  if (readers[i]) {
    readers[i].on('error', (data) => { console.log(`reader ${i}: ${data.code}`) }) 
  }
}

When I adapt the inputSlots array and attach a third keyboard, the keycode doesn't get logged to the console immediately when pressing a key.
I have to press a key on one of the other 2 attached keyboards, then the keycode from before and the keycode from the key that was just pressed are logged.
If i now press another key on this keyboard the thing starts again and i have to press a key on one of the other keyboards in order to log the keycode.

I am wondering if you have ever encountered this problem, or if you happen to know what could be the reason for this behaviour.

I also tried it with the 'keydown' and 'keypress' event, but that didnt change anything.

Thank you very much
Best regards

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions