hybridgroup.gobot/platforms/keyboard
deadprogram f225a66db9 docs: correct installation instructions to match latest versions
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-06-15 14:04:08 +02:00
..
LICENSE license: update license year to include 2017 2017-01-02 22:25:17 +01:00
README.md docs: correct installation instructions to match latest versions 2017-06-15 14:04:08 +02:00
doc.go docs: correct Keyboard README link 2016-12-21 10:52:46 +01:00
keyboard.go docs: Add missing godocs for keyboard platform 2016-11-30 23:32:20 +01:00
keyboard_driver.go keyboard: use new improved default namer to avoid API conflicts 2017-02-02 16:25:43 +01:00
keyboard_driver_test.go keyboard: increase test coverage 2017-04-06 10:49:34 +02:00
keyboard_test.go core: use canonical import domain of gobot.io for all code 2016-12-08 13:24:03 +01:00

README.md

Keyboard

This module implements support for keyboard events, wrapping the stty utility.

How to Install

go get -d -u gobot.io/x/gobot/...

How to Use

Example parsing key events

package main

import (
	"fmt"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/keyboard"
)

func main() {
	keys := keyboard.NewDriver()

	work := func() {
		keys.On(keyboard.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,
	)

	robot.Start()
}