keys

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 1 Imported by: 139

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Code       KeyCode
	Runes      []rune // Runes that the key produced. Most key pressed produce one single rune.
	AltPressed bool   // True when alt is pressed while the key is typed.
}

Key contains information about a keypress.

func (Key) String

func (k Key) String() (str string)

String returns a string representation of the key. (e.g. "a", "B", "alt+a", "enter", "ctrl+c", "shift-down", etc.)

Example:

k := keys.Key{Code: keys.Enter}
fmt.Println(k)
// Output: enter

type KeyCode

type KeyCode int

KeyCode is an integer representation of a non-rune key, such as Escape, Enter, etc. All other keys are represented by a rune and have the KeyCode: RuneKey.

Example:

k := Key{Code: RuneKey, Runes: []rune{'x'}, AltPressed: true}
if k.Code == RuneKey {
    fmt.Println(k.Runes)
    // Output: x

    fmt.Println(k.String())
    // Output: alt+x
}
const (
	Null      KeyCode = internal.KeyNull
	Break     KeyCode = internal.KeyExit
	Enter     KeyCode = internal.KeyCarriageReturn
	Backspace KeyCode = internal.KeyDelete
	Tab       KeyCode = internal.KeyHorizontalTabulation
	Esc       KeyCode = internal.KeyEscape
	Escape    KeyCode = internal.KeyEscape

	CtrlAt KeyCode = internal.KeyNull
	CtrlA  KeyCode = internal.KeyStartOfHeading
	CtrlB  KeyCode = internal.KeyStartOfText
	CtrlC  KeyCode = internal.KeyExit
	CtrlD  KeyCode = internal.KeyEndOfTransimission
	CtrlE  KeyCode = internal.KeyEnquiry
	CtrlF  KeyCode = internal.KeyAcknowledge
	CtrlG  KeyCode = internal.KeyBELL
	CtrlH  KeyCode = internal.KeyBackspace
	CtrlI  KeyCode = internal.KeyHorizontalTabulation
	CtrlJ  KeyCode = internal.KeyLineFeed
	CtrlK  KeyCode = internal.KeyVerticalTabulation
	CtrlL  KeyCode = internal.KeyFormFeed
	CtrlM  KeyCode = internal.KeyCarriageReturn
	CtrlN  KeyCode = internal.KeyShiftOut
	CtrlO  KeyCode = internal.KeyShiftIn
	CtrlP  KeyCode = internal.KeyDataLinkEscape
	CtrlQ  KeyCode = internal.KeyDeviceControl1
	CtrlR  KeyCode = internal.KeyDeviceControl2
	CtrlS  KeyCode = internal.KeyDeviceControl3
	CtrlT  KeyCode = internal.KeyDeviceControl4
	CtrlU  KeyCode = internal.KeyNegativeAcknowledge
	CtrlV  KeyCode = internal.KeySynchronousIdle
	CtrlW  KeyCode = internal.KeyEndOfTransmissionBlock
	CtrlX  KeyCode = internal.KeyCancel
	CtrlY  KeyCode = internal.KeyEndOfMedium
	CtrlZ  KeyCode = internal.KeySubstitution

	CtrlOpenBracket  KeyCode = internal.KeyEscape
	CtrlBackslash    KeyCode = internal.KeyFileSeparator
	CtrlCloseBracket KeyCode = internal.KeyGroupSeparator
	CtrlCaret        KeyCode = internal.KeyRecordSeparator
	CtrlUnderscore   KeyCode = internal.KeyUnitSeparator
	CtrlQuestionMark KeyCode = internal.KeyDelete
)

All control keys.

const (
	RuneKey KeyCode = -(iota + 1)
	Up
	Down
	Right
	Left
	ShiftTab
	Home
	End
	PgUp
	PgDown
	Delete
	Space
	CtrlUp
	CtrlDown
	CtrlRight
	CtrlLeft
	ShiftUp
	ShiftDown
	ShiftRight
	ShiftLeft
	CtrlShiftUp
	CtrlShiftDown
	CtrlShiftLeft
	CtrlShiftRight
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
	F16
	F17
	F18
	F19
	F20
)

Other keys.

func (KeyCode) String

func (k KeyCode) String() (str string)

Jump to

Keyboard shortcuts

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