Documentation ¶
Overview ¶
Package keyboard contains the Gobot drivers for keyboard support.
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() { 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() }
For further information refer to keyboard README: https://github.com/hybridgroup/gobot/blob/master/platforms/keyboard/README.md
Index ¶
Constants ¶
View Source
const ( Tilde = iota + 96 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
View Source
const ( Escape = 27 Spacebar = 32 )
View Source
const ( Zero = iota + 48 One Two Three Four Five Six Seven Eight Nine )
View Source
const ( ArrowUp = iota + 65 ArrowDown ArrowRight ArrowLeft )
View Source
const (
// Keyboard event
Key = "key"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyboardDriver ¶
func NewKeyboardDriver ¶
func NewKeyboardDriver(name string) *KeyboardDriver
func (*KeyboardDriver) Connection ¶
func (k *KeyboardDriver) Connection() gobot.Connection
func (*KeyboardDriver) Halt ¶
func (k *KeyboardDriver) Halt() (errs []error)
Halt stops camera driver
func (*KeyboardDriver) Name ¶
func (k *KeyboardDriver) Name() string
func (*KeyboardDriver) Start ¶
func (k *KeyboardDriver) Start() (errs []error)
Start initializes keyboard by grabbing key events as they come in and publishing a key event
Click to show internal directories.
Click to hide internal directories.