accelerator

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 2 Imported by: 0 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.

Documentation

Overview

Package accelerator parses Electron style keyboard accelerators such as "CmdOrCtrl+Shift+Z" into a platform neutral representation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accelerator

type Accelerator struct {
	Modifiers Modifiers
	// Key is either a single lower case character ("a", "1", ",") or one of
	// the named keys: F1-F24, Enter, Tab, Space, Backspace, Delete, Insert,
	// Escape, Up, Down, Left, Right, Home, End, PageUp, PageDown,
	// VolumeUp, VolumeDown, VolumeMute, MediaNextTrack, MediaPreviousTrack,
	// MediaStop, MediaPlayPause, PrintScreen, Num0-Num9, NumDec, NumAdd,
	// NumSub, NumMult, NumDiv, CapsLock, NumLock, ScrollLock.
	Key string
}

Accelerator is a parsed accelerator.

func Parse

func Parse(s, goos string) (Accelerator, error)

Parse parses an accelerator for the given GOOS. "CmdOrCtrl" resolves to Super (Command) on darwin and Ctrl elsewhere.

func (Accelerator) Has

func (a Accelerator) Has(m Modifiers) bool

Has reports whether all modifiers in m are set.

func (Accelerator) Keysym

func (a Accelerator) Keysym() string

Keysym returns the XKB (and X11) name of the key, as in "a", "comma", "Return", "F5" or "KP_Add".

func (Accelerator) String

func (a Accelerator) String() string

String formats the accelerator in canonical form.

func (Accelerator) XDGTrigger

func (a Accelerator) XDGTrigger() string

XDGTrigger formats the accelerator as a trigger of the XDG shortcuts specification, as in "CTRL+SHIFT+k", which desktop portals take.

type Modifiers

type Modifiers uint8

Modifiers is a bit set of modifier keys.

const (
	Super Modifiers = 1 << iota
	Ctrl
	Alt
	Shift
)

Modifier keys. Super is Command on macOS and the Windows/Super key elsewhere.

Jump to

Keyboard shortcuts

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