key

package
v0.0.0-...-b1976e4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Overview

Package key implements generic key definition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key int

Key represents a non-character key.

const (
	None Key = iota
	Enter
	Escape
	Space
	Tab
	Meta
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
	Backspace
	Delete
	Insert
	Home
	End
	PageUp
	PageDown
	Up
	Down
	Left
	Right
)

Known non-character keys.

Keys between None and Meta are not meta keys as they can be represented with a character, e.g. \n, \i, ' ', \t.

func StringToKey

func StringToKey(key string) Key

StringToKey parses the string presentation of a key back into a Key.

Returns None on invalid key name.

func (Key) String

func (i Key) String() string

type Press

type Press struct {
	Alt  bool
	Ctrl bool
	Key  Key  // Non-character key (e.g. F-keys, arrows, tab, space, etc). Set to None when not used.
	Ch   rune // Character key, e.g. letter, number. Set to rune(0) when not used.
}

Press represents a key press.

Only one of Key or Ch is set.

func StringToPress

func StringToPress(keyName string) Press

StringToPress parses a string and returns a Press.

func (Press) IsMeta

func (k Press) IsMeta() bool

IsMeta returns true if a key press is a meta key. This also includes characters with Ctrl or Alt held.

func (Press) IsValid

func (k Press) IsValid() bool

IsValid returns true if the object represents a key press.

func (Press) String

func (k Press) String() string

Jump to

Keyboard shortcuts

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