hybridgroup.gobot/platforms/keyboard
Thomas Kohler 27b9e04e7e fix keyboard tests and exclude opencv 2022-09-25 14:46:02 +02:00
..
LICENSE docs: update copyright date to 2018 2018-02-14 08:24:39 +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 add symbol keys for platform/keyboard 2020-10-28 21:12:12 +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 fix keyboard tests and exclude opencv 2022-09-25 14:46:02 +02: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()
}