hybridgroup.gobot/platforms/keyboard/doc.go

49 lines
929 B
Go
Raw Normal View History

2015-07-10 02:33:46 +08:00
/*
2016-07-14 00:44:47 +08:00
Package keyboard contains the Gobot drivers for keyboard support.
2015-07-10 02:33:46 +08:00
Installing:
Then you can install the package with:
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/keyboard
Example:
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/keyboard"
)
func main() {
keys := keyboard.NewDriver()
2015-07-10 02:33:46 +08:00
work := func() {
2016-10-17 14:59:23 +08:00
keys.On(keys.Event("key"), func(data interface{}) {
2015-07-10 02:33:46 +08:00
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.Start()
}
For further information refer to keyboard README:
https://github.com/hybridgroup/gobot/blob/master/platforms/keyboard/README.md
*/
package keyboard