Back to / io / key

Package key

v0.0.0 (83673ec)
Latest Go to latest
Published: Jul 26, 2020 | Licenses: MIT , Unlicense | Module:


Package key implements key and text events and operations.

The InputOp operations is used for declaring key input handlers. Use an implementation of the Queue interface from package ui to receive events.


Package Files


const (
	// Names for special keys.
	NameLeftArrow      = "←"
	NameRightArrow     = "→"
	NameUpArrow        = "↑"
	NameDownArrow      = "↓"
	NameReturn         = "⏎"
	NameEnter          = "⌤"
	NameEscape         = "⎋"
	NameHome           = "⇱"
	NameEnd            = "⇲"
	NameDeleteBackward = "⌫"
	NameDeleteForward  = "⌦"
	NamePageUp         = "⇞"
	NamePageDown       = "⇟"
	NameTab            = "⇥"
const ModShortcut = ModCtrl

ModShortcut is the platform's shortcut modifier, usually the Ctrl key. On Apple platforms it is the Cmd key.

type EditEvent

type EditEvent struct {
	Text string

An EditEvent is generated when text is input.

func (EditEvent) ImplementsEvent

func (EditEvent) ImplementsEvent()

type Event

type Event struct {
	// Name of the key. For letters, the upper case form is used, via
	// unicode.ToUpper. The shift modifier is taken into account, all other
	// modifiers are ignored. For example, the "shift-1" and "ctrl-shift-1"
	// combinations both give the Name "!" with the US keyboard layout.
	Name string
	// Modifiers is the set of active modifiers when the key was pressed.
	Modifiers Modifiers

An Event is generated when a key is pressed. For text input use EditEvent.

func (Event) ImplementsEvent

func (Event) ImplementsEvent()

func (Event) String

func (e Event) String() string

type FocusEvent

type FocusEvent struct {
	Focus bool

A FocusEvent is generated when a handler gains or loses focus.

func (FocusEvent) ImplementsEvent

func (FocusEvent) ImplementsEvent()

type HideInputOp

type HideInputOp struct{}

HideInputOp request that any on screen text input be hidden.

func (HideInputOp) Add

func (h HideInputOp) Add(o *op.Ops)

type InputOp

type InputOp struct {
	Tag   event.Tag
	Focus bool

InputOp declares a handler ready for key events. Key events are in general only delivered to the focused key handler. Set the Focus flag to request the focus.

func (InputOp) Add

func (h InputOp) Add(o *op.Ops)

type Modifiers

type Modifiers uint32


const (
	// ModCtrl is the ctrl modifier key.
	ModCtrl Modifiers = 1 << iota
	// ModCommand is the command modifier key
	// found on Apple keyboards.
	// ModShift is the shift modifier key.
	// ModAlt is the alt modifier key, or the option
	// key on Apple keyboards.
	// ModSuper is the "logo" modifier key, often
	// represented by a Windows logo.

func (Modifiers) Contain

func (m Modifiers) Contain(m2 Modifiers) bool

Contain reports whether m contains all modifiers in m2.

func (Modifiers) String

func (m Modifiers) String() string
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier