Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

library is not working with more than 2 keyboards

未关闭
#6 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript

调研方向

从 example 文件夹中的修改后示例开始,使用 /dev/input/event21 和 /dev/input/event23 重现该行为,然后按照描述添加第三个键盘。在 Ubuntu 或 Raspberry Pi 上跟踪库如何读取并发出每个设备的事件;当所有已连接键盘的按键事件都能立即且独立地记录时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

help wanted

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

主要语言
JavaScript
星标
65
派生
22
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lsongdev/input-event 的其他 Issue

查看 lsongdev/input-event 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。