getkey

package module
v0.0.0-...-5735b84 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: Unlicense Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Read a single key from the terminal. It's especially helpful with shell scripts. For example run this then press a key combination like Ctrl-Alt-j:

$ echo "You pressed: $(getkey)"
You pressed: Ctrl-Alt-j

Installation

go get -u github.com/mndrix/getkey/...

Documentation

Overview

Package getkey retrieves a single key press from the terminal and translates it into a descriptive string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKey

func GetKey() (string, error)

GetKey waits for the user to press a key and then returns a string describing what was pressed. Alphanumeric characters and punctuation are represented as themselves. Modifier keys are represented as Ctrl-, Alt-, Esc-, and Shift- prefixes (in that order) on the base key. For example, holding down Control and Alt while pressing the L key produces "Ctrl-Alt-L".

func Restore

func Restore() (err error)

Restore restores the terminal to the state it was in during init().

You don't usually need to call this function because GetKey calls it automatically when it returns. However, it can be helpful to call during program exit if GetKey was running in a separate goroutine.

func SetDebug

func SetDebug(enable bool)

SetDebug enables or disable debugging log messages.

Types

This section is empty.

Directories

Path Synopsis
cmd
getkey command

Jump to

Keyboard shortcuts

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