kb

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 4 Imported by: 146 modules, 101 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 kb provides keyboard mappings for Chrome DOM Keys for use with input events.

Index

Constants

Key event types for the Type field of an input.DispatchKeyEventParams.

View Source
const (
	Backspace            = "\b"
	Tab                  = "\t"
	Enter                = "\r"
	Escape               = "\u001b"
	Quote                = "'"
	Backslash            = "\\"
	Delete               = "\u007f"
	Alt                  = "\u0102"
	CapsLock             = "\u0104"
	Control              = "\u0105"
	Fn                   = "\u0106"
	FnLock               = "\u0107"
	Hyper                = "\u0108"
	Meta                 = "\u0109"
	NumLock              = "\u010a"
	ScrollLock           = "\u010c"
	Shift                = "\u010d"
	Super                = "\u010e"
	ArrowDown            = "\u0301"
	ArrowLeft            = "\u0302"
	ArrowRight           = "\u0303"
	ArrowUp              = "\u0304"
	End                  = "\u0305"
	Home                 = "\u0306"
	PageDown             = "\u0307"
	PageUp               = "\u0308"
	Clear                = "\u0401"
	Copy                 = "\u0402"
	Cut                  = "\u0404"
	Insert               = "\u0407"
	Paste                = "\u0408"
	Redo                 = "\u0409"
	Undo                 = "\u040a"
	Again                = "\u0502"
	Cancel               = "\u0504"
	ContextMenu          = "\u0505"
	Find                 = "\u0507"
	Help                 = "\u0508"
	Pause                = "\u0509"
	Props                = "\u050b"
	Select               = "\u050c"
	ZoomIn               = "\u050d"
	ZoomOut              = "\u050e"
	BrightnessDown       = "\u0601"
	BrightnessUp         = "\u0602"
	Eject                = "\u0604"
	LogOff               = "\u0605"
	Power                = "\u0606"
	PrintScreen          = "\u0608"
	WakeUp               = "\u060b"
	Convert              = "\u0705"
	ModeChange           = "\u070b"
	NonConvert           = "\u070d"
	HangulMode           = "\u0711"
	HanjaMode            = "\u0712"
	Hiragana             = "\u0716"
	KanaMode             = "\u0718"
	Katakana             = "\u071a"
	ZenkakuHankaku       = "\u071d"
	F1                   = "\u0801"
	F2                   = "\u0802"
	F3                   = "\u0803"
	F4                   = "\u0804"
	F5                   = "\u0805"
	F6                   = "\u0806"
	F7                   = "\u0807"
	F8                   = "\u0808"
	F9                   = "\u0809"
	F10                  = "\u080a"
	F11                  = "\u080b"
	F12                  = "\u080c"
	F13                  = "\u080d"
	F14                  = "\u080e"
	F15                  = "\u080f"
	F16                  = "\u0810"
	F17                  = "\u0811"
	F18                  = "\u0812"
	F19                  = "\u0813"
	F20                  = "\u0814"
	F21                  = "\u0815"
	F22                  = "\u0816"
	F23                  = "\u0817"
	F24                  = "\u0818"
	Close                = "\u0a01"
	MailForward          = "\u0a02"
	MailReply            = "\u0a03"
	MailSend             = "\u0a04"
	MediaPlayPause       = "\u0a05"
	MediaStop            = "\u0a07"
	MediaTrackNext       = "\u0a08"
	MediaTrackPrevious   = "\u0a09"
	New                  = "\u0a0a"
	Open                 = "\u0a0b"
	Print                = "\u0a0c"
	Save                 = "\u0a0d"
	SpellCheck           = "\u0a0e"
	AudioVolumeDown      = "\u0a0f"
	AudioVolumeUp        = "\u0a10"
	AudioVolumeMute      = "\u0a11"
	LaunchApplication2   = "\u0b01"
	LaunchCalendar       = "\u0b02"
	LaunchMail           = "\u0b03"
	LaunchMediaPlayer    = "\u0b04"
	LaunchMusicPlayer    = "\u0b05"
	LaunchApplication1   = "\u0b06"
	LaunchScreenSaver    = "\u0b07"
	LaunchSpreadsheet    = "\u0b08"
	LaunchWebBrowser     = "\u0b09"
	LaunchContacts       = "\u0b0c"
	LaunchPhone          = "\u0b0d"
	LaunchAssistant      = "\u0b0e"
	BrowserBack          = "\u0c01"
	BrowserFavorites     = "\u0c02"
	BrowserForward       = "\u0c03"
	BrowserHome          = "\u0c04"
	BrowserRefresh       = "\u0c05"
	BrowserSearch        = "\u0c06"
	BrowserStop          = "\u0c07"
	ChannelDown          = "\u0d0a"
	ChannelUp            = "\u0d0b"
	ClosedCaptionToggle  = "\u0d12"
	Exit                 = "\u0d15"
	Guide                = "\u0d22"
	Info                 = "\u0d25"
	MediaFastForward     = "\u0d2c"
	MediaLast            = "\u0d2d"
	MediaPause           = "\u0d2e"
	MediaPlay            = "\u0d2f"
	MediaRecord          = "\u0d30"
	MediaRewind          = "\u0d31"
	Settings             = "\u0d43"
	ZoomToggle           = "\u0d4e"
	AudioBassBoostToggle = "\u0e02"
	SpeechInputToggle    = "\u0f02"
	AppSwitch            = "\u1001"
)

DOM keys.

Variables

View Source
var Keys = map[rune]*Key{}/* 229 elements not displayed */

Keys is the map of unicode characters to their DOM key data.

Functions

func Encode

func Encode(r rune) []*input.DispatchKeyEventParams

Encode encodes a keyDown, char, and keyUp sequence for the specified rune.

func EncodeUnidentified

func EncodeUnidentified(r rune) []*input.DispatchKeyEventParams

EncodeUnidentified encodes a keyDown, char, and keyUp sequence for an unidentified rune.

Types

type Key

type Key struct {
	// Code is the key code:
	Code string
	// Key is the key value:
	Key string
	// Text is the text for printable keys:
	Text string
	// Unmodified is the unmodified text for printable keys:
	Unmodified string
	// Native is the native scan code.
	Native int64
	// Windows is the Windows scan code.
	Windows int64
	// Shift indicates whether the Shift modifier is sent.
	Shift bool
	// Print indicates whether the character is a printable character
	// (that is, whether a "char" event is generated).
	Print bool
}

Key contains information for generating a key press based off the unicode value.

Example data for the following runes:

Runes      | '\r'  '\n'  | ','  '<'   | 'a'   'A'  | '\u0a07'    |
-----------|-------------|------------|------------|-------------|
Code       | "Enter"     | "Comma"    | "KeyA"     | "MediaStop" |
Key        | "Enter"     | ","   "<"  | "a"   "A"  | "MediaStop" |
Text       | "\r"  "\r"  | ","   "<"  | "a"   "A"  | ""          |
Unmodified | "\r"  "\r"  | ","   ","  | "a"   "a"  | ""          |
Native     | 0x13  0x13  | 0xbc  0xbc | 0x61  0x41 | 0x00ae      |
Windows    | 0x13  0x13  | 0xbc  0xbc | 0x61  0x41 | 0xe024      |
Shift      | false false | false true | false true | false       |
Print      | true  true  | true  true | true  true | false       |

type Modifier added in v0.17.0

type Modifier int64

Modifier is a bit field of pressed modifier keys. Convert it with int64 to set the Modifiers field of an input event.

const (
	ModifierNone  Modifier = 0
	ModifierAlt   Modifier = 1
	ModifierCtrl  Modifier = 2
	ModifierMeta  Modifier = 4
	ModifierShift Modifier = 8

	// ModifierCommand is an alias for ModifierMeta.
	ModifierCommand = ModifierMeta
)

Modifier values.

func (Modifier) Int64 added in v0.17.0

func (m Modifier) Int64() int64

Int64 returns the Modifier as an int64 value.

func (Modifier) String added in v0.17.0

func (m Modifier) String() string

String returns the Modifier as a string value.

Jump to

Keyboard shortcuts

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