keypress

package
v0.0.0-...-7ba8725 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package keypress is a library for advanced keypress detection and parsing.

It provides a callback with both a human-readable name for the event detected, along with the raw data behind it.

The following are supported human-readable names:

Enter
Esc

Mouse Moved
Mouse Down
Mouse Up

Scroll Up
Scroll Down

[letter]
Alt+[letter]
Alt+Shift+[letter]
Ctrl+[letter]

Up
Down
Left
Right

Shift+[arrow]
Alt+[arrow]
Alt+Shift+[arrow]
Ctrl+[arrow]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTermSize

func GetTermSize() (int, int, error)

GetTermSize returns the terminal dimensions w, h, err

func Listen

func Listen(callback func(parsedData interface{}, rawData []byte))

Listen is a blocking function that indefinitely listens for keypresses. When it detects a keypress, it passes on to the callback a human-readable interpretation of the event (e.g. Alt+Shift+Up) along with the raw string of text received by the terminal.

func ShouldProcessMouse

func ShouldProcessMouse(should bool)

ShouldProcessMouse controls whether typical mouse actions (e.g. selection) should be disabled in exhange for i3-mux-specific features

func Shutdown

func Shutdown()

Shutdown cleans up the terminal state

Types

type AltArrow

type AltArrow struct {
	Direction
}

AltArrow is for alt+[arrow key]

type AltChar

type AltChar struct {
	Char rune
}

AltChar is for alt+[character]

type AltShiftArrow

type AltShiftArrow struct {
	Direction
}

AltShiftArrow is for alt+shift+[arrow key]

type AltShiftChar

type AltShiftChar struct {
	Char rune
}

AltShiftChar is for alt+shift+[character]

type Arrow

type Arrow struct {
	Direction
}

Arrow is for the arrow keys

type Character

type Character struct {
	Char rune
}

Character is for when a single non-modifier key is pressed. It has a long name to prevent confusion with Char used in other structs

type CtrlArrow

type CtrlArrow struct {
	Direction
}

CtrlArrow is for ctrl+[arrow key]

type CtrlChar

type CtrlChar struct {
	Char rune
}

CtrlChar is for ctrl+[character]

type Direction

type Direction uint

Direction is Up, Down, Left, or Right

const (
	Up Direction = iota
	Down
	Left
	Right
)

Arrow direction

type Enter

type Enter struct{}

Enter is the same thing as \n or return

type Esc

type Esc struct{}

Esc is for when the escape key is pressed

type MouseDown

type MouseDown struct {
	X, Y int
}

MouseDown is for when the primary mouse button is pressed down

type MouseMove

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

MouseMove is for when the terminal reports mouse movement

type MouseUp

type MouseUp struct {
	X, Y int
}

MouseUp is for when the primary mouse button is no longer being pressed

type Resize

type Resize struct {
	W, H int
}

Resize is for host terminal resize eventd

type ScrollDown

type ScrollDown struct{}

ScrollDown moves the viewport down, and the screen contents up

type ScrollUp

type ScrollUp struct{}

ScrollUp moves the viewport up, and the screen contents down

type ShiftArrow

type ShiftArrow struct {
	Direction
}

ShiftArrow is for shift+[arrow key]

Jump to

Keyboard shortcuts

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