94d78d777a
Signed-off-by: deadprogram <ron@hybridgroup.com> |
||
---|---|---|
.. | ||
LICENSE | ||
README.md | ||
doc.go | ||
keyboard.go | ||
keyboard_driver.go | ||
keyboard_driver_test.go | ||
keyboard_test.go |
README.md
Keyboard
This module implements support for keyboard events, wrapping the stty
utility.
How to Install
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/keyboard
How to Use
Example parsing key events
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/keyboard"
)
func main() {
gbot := gobot.NewGobot()
keys := keyboard.NewKeyboardDriver("keyboard")
work := func() {
gobot.On(keys.Event("key"), func(data interface{}) {
key := data.(keyboard.KeyEvent)
if key.Key == keyboard.A {
fmt.Println("A pressed!")
} else {
fmt.Println("keyboard event!", key, key.Char)
}
})
}
robot := gobot.NewRobot("keyboardbot",
[]gobot.Connection{},
[]gobot.Device{keys},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}