1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00

49 lines
958 B
Go
Raw Normal View History

2015-07-09 11:33:46 -07:00
/*
2016-07-13 10:44:47 -06:00
Package keyboard contains the Gobot drivers for keyboard support.
2015-07-09 11:33:46 -07:00
Installing:
Then you can install the package with:
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
2015-07-09 11:33:46 -07:00
Example:
package main
import (
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/keyboard"
2015-07-09 11:33:46 -07:00
)
func main() {
keys := keyboard.NewDriver()
2015-07-09 11:33:46 -07:00
work := func() {
keys.On(keyboard.Key, func(data interface{}) {
2015-07-09 11:33:46 -07: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,
)
robot.Start()
2015-07-09 11:33:46 -07:00
}
For further information refer to keyboard README:
https://github.com/hybridgroup/gobot/blob/master/platforms/keyboard/README.md
2015-07-09 11:33:46 -07:00
*/
package keyboard // import "gobot.io/x/gobot/v2/platforms/keyboard"