keylayout

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT, MIT, Unlicense Imports: 3 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 keylayout tracks which key name the current keyboard layout gives each physical key. Platform backends report whole layouts where they can; the input router fills in the rest from unmodified key presses. The io/key package reads it through key.Code.

Index

Constants

This section is empty.

Variables

View Source
var US = map[string]string{
	"KeyA": "A", "KeyB": "B", "KeyC": "C", "KeyD": "D", "KeyE": "E", "KeyF": "F", "KeyG": "G",
	"KeyH": "H", "KeyI": "I", "KeyJ": "J", "KeyK": "K", "KeyL": "L", "KeyM": "M", "KeyN": "N",
	"KeyO": "O", "KeyP": "P", "KeyQ": "Q", "KeyR": "R", "KeyS": "S", "KeyT": "T", "KeyU": "U",
	"KeyV": "V", "KeyW": "W", "KeyX": "X", "KeyY": "Y", "KeyZ": "Z",
	"Digit0": "0", "Digit1": "1", "Digit2": "2", "Digit3": "3", "Digit4": "4",
	"Digit5": "5", "Digit6": "6", "Digit7": "7", "Digit8": "8", "Digit9": "9",
	"Backquote": "`", "Minus": "-", "Equal": "=", "BracketLeft": "[", "BracketRight": "]",
	"Backslash": `\`, "Semicolon": ";", "Quote": "'", "Comma": ",", "Period": ".", "Slash": "/",
	"IntlBackslash": `\`, "Space": "Space",

	"Numpad0": "0", "Numpad1": "1", "Numpad2": "2", "Numpad3": "3", "Numpad4": "4",
	"Numpad5": "5", "Numpad6": "6", "Numpad7": "7", "Numpad8": "8", "Numpad9": "9",
}

US is the key name at each physical key on a US QWERTY layout, which is also how codes are named ("KeyQ" is the key QWERTY types Q with).

Functions

func CodeFor

func CodeFor(name string) string

CodeFor guesses the physical key for a key name, as on a US layout, for events from platforms that don't report physical keys.

func Evdev

func Evdev(code uint32) string

Evdev names the physical key for a Linux evdev key code, which X11 and Wayland keycodes are offset from by 8. Windows scan codes for the same keys have the same values.

func EvdevCodes

func EvdevCodes() []uint32

EvdevCodes lists the evdev key codes Evdev names, for querying a whole layout.

func Learn

func Learn(code, name string)

Learn records what a key press shows the current layout types with code. Where that isn't what was thought, the layout has changed or was never reported, so a common layout that agrees with the press takes over every key: one press is enough to relabel them all.

func Mac

func Mac(code uint16) string

Mac names the physical key for a macOS virtual key code (kVK_*).

func Name

func Name(code string) string

Name returns the key name the current layout gives the key at code, falling back to the US layout's for keys not yet reported.

func Reset

func Reset()

Reset forgets every reported name, for a layout change.

func Set

func Set(code, name string)

Set records that the current layout types name with the key at code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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