sendkeys

package module
Version: v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

README

sendkeys GoDoc go.dev reference

Package sendkeys provides functions to simulate user input in the terminal by sending keys to a TTY. Useful especially to test terminal programs that run in raw mode. See the package documentation for details, API reference and usage example (alternatively, on pkg.go.dev).

It only works on Unix-like systems. Note that programs using this will require sudo-like privileges.

License

The BSD 3-Clause license.

Documentation

Overview

Package sendkeys simulates user input in a terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Target

type Target struct {
	// contains filtered or unexported fields
}

Target represents the tty to which the keys are sent. Create one by calling Open and send keys using Target.SendRunes or Target.SendBytes. The Target must be closed after use.

func Open

func Open(ttyPath string, delay time.Duration) (*Target, error)

Open returns a Target that sends keys to the specified TTY. The delay is the time to wait before sending each separate string when SendRunes or SendBytes is called.

func (*Target) Close

func (t *Target) Close() error

Close releases the resources used by the Target.

func (*Target) SendBytes

func (t *Target) SendBytes(strs ...string) (int, error)

SendBytes is like SendRunes except it sends each byte separately, instead if each rune.

func (*Target) SendRunes

func (t *Target) SendRunes(strs ...string) (int, error)

SendRunes sends each rune of each string the the Target. All runes of a given string are sent without delay, and the target's delay is applied between each string.

Source Files

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL