package main
import (
"fmt"
"github.com/MarinX/keylogger"
)
func main() {
// k, err := keylogger.New("/dev/input/event14")
k, err := keylogger.New("/dev/input/event3")
if err != nil {
fmt.Println(err)
return
}
defer k.Close()
events := k.Read()
for e := range events {
switch e.Type {
case keylogger.EvKey:
if e.KeyPress() {
fmt.Println("[event] press key ", e.KeyString())
}
}
}
}
I have two keyboards. One original from the laptop (/dev/input/event3) and one connected to laptop via USB (/dev/input/event14). When I use keylogger.New("/dev/input/event3") and press something on the laptop keyboard everything works as I expect. However, when I change to keylogger.New("/dev/input/event14"), that is, to my other keyboard and press something on that keyboard, nothing happens.
The result of sudo lsinput:
....
/dev/input/event3
bustype : BUS_I8042
vendor : 0x1
product : 0x1
version : 43962
name : "AT Translated Set 2 keyboard"
phys : "isa0060/serio0/input0"
bits ev : (null) (null) (null) (null) (null)
....
/dev/input/event14
bustype : BUS_USB
vendor : 0x258a
product : 0x3a
version : 273
name : "SINO WEALTH Gaming KB Keyboard"
phys : "usb-0000:04:00.3-2.3/input1"
uniq : ""
bits ev : (null) (null) (null) (null)
....
My code:
I have two keyboards. One original from the laptop (
/dev/input/event3
) and one connected to laptop via USB (/dev/input/event14
). When I usekeylogger.New("/dev/input/event3")
and press something on the laptop keyboard everything works as I expect. However, when I change tokeylogger.New("/dev/input/event14")
, that is, to my other keyboard and press something on that keyboard, nothing happens.The result of
sudo lsinput
:Why is this happening? What should I do?