-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.go
40 lines (30 loc) · 777 Bytes
/
scan.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
mykeyboard "github.com/jedipunkz/mygobot/pkg/keyboard"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/keyboard"
)
type scanCommand struct{}
func (c *scanCommand) Help() string {
return "Usage: remo-numpad scan"
}
func (c *scanCommand) Synopsis() string {
return "scan your key inputs"
}
func (c *scanCommand) Run(args []string) int {
mykeyboard := mykeyboard.NewMyKeyboard()
work := func() {
mykeyboard.KeyDriver.On(keyboard.Key, func(data interface{}) {
pushedKey := data.(keyboard.KeyEvent)
fmt.Println("Your Key: ", pushedKey, " ", pushedKey.Char, " ", pushedKey.Bytes)
})
}
robot := gobot.NewRobot("keyboardbot",
[]gobot.Connection{},
[]gobot.Device{mykeyboard.KeyDriver},
work,
)
robot.Start()
return 0
}